【发布时间】:2016-03-14 13:37:59
【问题描述】:
当我使用 moveToElement 时,我收到错误“org.openqa.selenium.interactions.MoveTargetOutOfBoundsException:元素内的偏移量无法滚动到视图中:(0, 0):命令持续时间或超时:34 毫秒”。下面的代码用于此
WebDriverWait waitForEditI = new WebDriverWait(driver, 20);
waitForEditI.until(ExpectedConditions.elementToBeClickable(editContactI));
Actions action = new Actions(driver);
action.moveToElement(editContactI).moveToElement(editContactIEdit).click().build().perform();
网页元素是
@FindBy(how = How.CSS, using = "div#evy_aboutme_content_id08 div.evy_edit_overflow > div.evy_rltn_icon2 i")
WebElement editContactI;
@FindBy(how = How.CSS, using = "div#evy_aboutme_content_id08 div.evy_aboutme_education_content.ng-scope a:nth-child(1)")
WebElement editContactIEdit;
如下图,首先我需要将 i 元素(黄色圆圈标记)悬停并点击编辑(黑色圆圈)。
我已经尝试了以下所有选项。但没有任何效果。它的位置是动态的。
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("scroll(250, 0)");
和
Actions actions = new Actions(driver);
actions.keyDown(Keys.CONTROL).sendKeys(Keys.END).perform();
请帮助我。
【问题讨论】:
标签: selenium selenium-webdriver