【问题标题】:Selenium : NoSuchElementException in IE11 JAVASelenium:IE11 JAVA 中的 NoSuchElementException
【发布时间】:2016-03-29 07:03:16
【问题描述】:

我正在尝试在 IE11 中执行 selenium webdriver java 代码,即使在页面完全加载后它也会抛出“NoSuchElementException”。

  1. Web 驱动程序:IEDriverServer_Win32_2.53.0
  2. IE 版本:11
  3. 硒:selenium-server-standalone-2.53.0.jar
  4. java : jdk1.8

应用程序由 LoginPage 和主页组成。在首页,点击“添加客户”按钮即可添加客户详细信息。

登录到应用程序在 IE11 中成功执行。登录后,“添加客户”按钮抛出 NoSuchElementException。

以下是selenium Java 代码:

     driver.findElement(By.id("btnAddCustToQueue")).click();

以下是jsp代码:

    <DIV class="blueButton floatLeft pie_first-child" id=btnAddCustToQueue onclick=openAddCustomer() _pieId="_158">Add<BR>Customer </DIV>

下面是抛出的异常:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to find element with id == btnAddCustToQueue (WARNING: The server did not provide any stacktrace information)

我已使用显式等待“添加客户”按钮加载。在这种情况下,“TimeOutException”如下所示:

     Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 30 seconds waiting for element to be clickable: By.id: btnAddCustToQueue

相同的代码在 CHROME 浏览器上运行良好。 我不确定最新的IE是否有问题。

提前致谢。

【问题讨论】:

  • 我也面临同样的问题。你有解决办法吗?
  • 你能在公共 URL 上复制这个吗?

标签: java selenium selenium-webdriver internet-explorer-11


【解决方案1】:

试试这个:

driver.findElement(By.xpath("//DIV[contains(@id,'btnAddCustToQueue')")).click();

如果您上传的 HTML 是这样的,它应该可以工作

下次上传您正在尝试的网页,以便我们尝试一下,也许会找到更好的方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-03
    相关资源
    最近更新 更多