セレンMoveTargetOutOfBoundsException偶数番目の要素にスクロールした後、

ルボミール:
new Actions(data).moveToElement(element,x,y).perform();

このコードは、と検索を働いた:セレン3.8.1、クロム63、chromedriver 2.3.8

最終的にアップグレードした後:セレン3.14、クロム75、chromedriver 75.0.3770.9

私はエラーを取得しています:

org.openqa.selenium.interactions.MoveTargetOutOfBoundsException

私はこれを示唆されました。

バージョン75で、W3C準拠のChromedriverのスイッチを使用すると、ここでそれらに対してアクションを使用する前に、ビューに任意の要素をスクロールする必要が

私はこのコードを追加したので、(isVisibleInViewportからですこちら

  private boolean isVisibleInViewport(WebElement element) {
      return (boolean)((JavascriptExecutor)data).executeScript(
            "var elem = arguments[0],                 " +
            "  box = elem.getBoundingClientRect(),    " +
            "  cx = box.left + box.width / 2,         " +
            "  cy = box.top + box.height / 2,         " +
            "  e = document.elementFromPoint(cx, cy); " +
            "for (; e; e = e.parentElement) {         " +
            "  if (e === elem)                        " +
            "    return true;                         " +
            "}                                        " +
            "return false;                            "
            , element);
  }

public void moveToElement(WebElement element, int x,int y){
    if (!isVisibleInViewport(element)) ((JavascriptExecutor) data).executeScript("arguments[0].scrollIntoView();", element);
    new Actions(data).moveToElement(element,x,y).perform();
}

しかし、私はまだ同じエラーを取得しています:

org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: move target out of bounds
  (Session info: chrome=75.0.3770.100)
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'TEST_VIRTUAL_114', ip: '192.168.215.2', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 75.0.3770.100, chrome: {chromedriverVersion: 75.0.3770.90 (a6dcaf7e3ec6f..., userDataDir: C:\Users\TestVirtualPC\AppData\Lo...}, goog:chromeOptions: {debuggerAddress: localhost:63560}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}

だから、問題はその後何ですか?

Batuhan Kilic:

あなたは同じ問題に直面している場合、私はわからないが、私はversion75に私のchromedriverを更新し、同様の問題がありました。

前に私は、左上隅からのオフセットを使用していたし、それがchromedriverの以前のバージョンのために罰金を働いていました。

しかし、今から(Version75)に私が使用する必要が中心からオフセットをウェブ要素の。

ウェブ要素の中心から座標を計算するには、私の問題を解決しました。

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=235791&siteId=1