如何处理"MoveTargetOutOfBoundsException"在Selenium WebDriver中

编程入门 行业动态 更新时间:2024-10-10 03:28:11
本文介绍了如何处理"MoveTargetOutOfBoundsException"在Selenium WebDriver中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我使用moveToElement时,出现错误" org.openqa.selenium.interactions.MoveTargetOutOfBoundsException:元素内的偏移无法滚动到视图中:(0,0):命令持续时间或超时:34毫秒".下面的代码用于此

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();

和网络元素是

@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元素(标记为黄色圆圈)悬停并单击编辑(黑色圆圈).

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)");

Actions actions = new Actions(driver); actions.keyDown(Keys.CONTROL).sendKeys(Keys.END).perform();

请帮助我.

推荐答案

如果在IE浏览器中遇到上述异常.请按照以下步骤操作:

if you are getting the above mentioned exception in IE browser. Please follow the below steps:

  • 返回IE并检查缩放级别是否设置为100%
  • 如果将缩放级别设置为100%,并且您的网络应用仅在浏览器的一半中显示,则说明它存在分辨率问题,
  • 转到您的桌面并更改屏幕分辨率:在我的情况下,1366 * 768有效.
  • 现在返回IE浏览器,将缩放级别设置为100(它将根据屏幕分辨率重置).
  • 现在,请确保您的网络应用程序能够像在其他浏览器中看到的那样显示.
  • 最后再次运行您的代码,现在您应该不会看到此错误. :)

    Finally run your code again and now you should not see this error. :)

    更多推荐

    如何处理"MoveTargetOutOfBoundsException"在Selenium WebDriver中

    本文发布于:2023-11-27 16:23:12,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1638732.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:如何处理   quot   MoveTargetOutOfBoundsException   Selenium   WebDriver

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!