Reputation: 125
When I am using moveToElement, I am getting an error "org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: Offset within element cannot be scrolled into view: (0, 0): Command duration or timeout: 34 milliseconds". Below code is used for that
WebDriverWait waitForEditI = new WebDriverWait(driver, 20);
waitForEditI.until(ExpectedConditions.elementToBeClickable(editContactI));
Actions action = new Actions(driver);
action.moveToElement(editContactI).moveToElement(editContactIEdit).click().build().perform();
and the web elements are
@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;
As the below image, first I need to hover i element (which is marked in yellow circle) and click the edit (black circle).
I have tried all below options .But nothing is working. The position of it is dynamic.
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("scroll(250, 0)");
and
Actions actions = new Actions(driver);
actions.keyDown(Keys.CONTROL).sendKeys(Keys.END).perform();
Please help me.
Upvotes: 2
Views: 23004
Reputation: 11
if you are getting the above mentioned exception in IE browser. Please follow the below steps:
Finally run your code again and now you should not see this error. :)
Upvotes: 0
Reputation: 125
This solution worked for me
((JavascriptExecutor)driver).executeScript("$('div#evy_aboutme_content_id08 div.evy_edit_overflow > div.evy_rltn_icon2 i').hover();");
((JavascriptExecutor)driver).executeScript("$('div#evy_aboutme_content_id08 div.evy_aboutme_education_content.ng-scope a:nth-child(1)').click();");
Upvotes: 0
Reputation: 25611
I would separate the different actions. I would hover using Actions
then do a "normal" click()
.
Actions builder = new Actions(driver);
builder.moveToElement(editContactI).perform();
driver.findElement(editContactIEdit).click();
Upvotes: 2