当前位置: 首页 > 面试题库 >

IE的Selenium WebDriver错误

罗伟兆
2023-03-14
问题内容

我正在尝试使用seleniumwebdriver,junit和ant
build自动化测试用例。自从早上以来,我收到了一些奇怪的错误。一个测试用例包含按钮单击命令。该测试在Chrome和FF上运行成功,但在IE上未成功。此前,至少有人说无法找到元素X,但是有人说服务器未提供任何信息。

Testcase: testMethod took 10.342 sec
    Caused an ERROR
Cannot click on element (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 172 milliseconds
Build info: version: '2.23.1', revision: '17143', time: '2012-06-08 18:59:04'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_33'
Driver info: driver.version: RemoteWebDriver
Session ID: 8dfc5072-2755-40a7-bb32-05708c51101f
com.thoughtworks.selenium.SeleniumException: Cannot click on element (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 172 milliseconds
Build info: version: '2.23.1', revision: '17143', time: '2012-06-08 18:59:04'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_33'
Driver info: driver.version: RemoteWebDriver
Session ID: 8dfc5072-2755-40a7-bb32-05708c51101f
    at org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:41)
    at org.openqa.selenium.internal.seleniumemulation.Timer.run(Timer.java:38)
    at org.openqa.selenium.WebDriverCommandProcessor.execute(WebDriverCommandProcessor.java:144)
    at org.openqa.selenium.WebDriverCommandProcessor.doCommand(WebDriverCommandProcessor.java:74)
    at com.thoughtworks.selenium.DefaultSelenium.click(DefaultSelenium.java:193)
    at dmswebui.IE.TestLogin.testMethod(TestLogin.java:19)
Caused by: org.openqa.selenium.ElementNotVisibleException: Cannot click on element (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 172 milliseconds
Build info: version: '2.23.1', revision: '17143', time: '2012-06-08 18:59:04'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_33'
Driver info: driver.version: RemoteWebDriver
Session ID: 8dfc5072-2755-40a7-bb32-05708c51101f
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:458)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:244)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:77)
    at org.openqa.selenium.internal.seleniumemulation.Click.handleSeleneseCommand(Click.java:36)
    at org.openqa.selenium.internal.seleniumemulation.Click.handleSeleneseCommand(Click.java:1)
    at org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:32)

问题答案:

在触发点击事件之前插入以下代码块

for (int second = 0;; second++) {
    if (second >= 60) return "Page load failed";
    try {
        if (session().isTextPresent("Logoff")) 
            break;
    } 
    catch (Exception e) {}
    Thread.sleep(1000);
}

就我而言,我拥有测试用例的超类,这就是为什么我可以做的原因

session().somecommand

但是,您可以将我的解决方案转化为您的解决方案。



 类似资料:
  • 问题内容: 我一直在为FF写我的脚本,但希望他们所做的工作很少,它们也可以在其他浏览器上运行,但是IE驱动程序似乎存在按钮问题? 我在按钮上有一个简单的webelement.click(),不会引发错误,但不单击按钮。在FF它的罚款。我可以获取文本,获取价值,所以我知道find语句是可以的,只是不会单击它。 想法或帮助会很棒 只是做 HTML-控件上有3个按钮,我现在只对登录感兴趣 问题答案: 遇

  • 多年以来,IE 一直都是最难于调试JavaScript 错误的浏览器。IE 给出的错误消息一般很短又语焉不详,而且上下文信息也很少,有时甚至一点都没有。但作为用户最多的浏览器,如何看懂IE 给出的错误也是最受关注的。下面几小节将分别探讨一些在IE 中难于调试的JavaScript 错误。 17.4.1 操作终止在IE8 之前的版本中,存在一个相对于其他浏览器而言,最令人迷惑、讨厌,也最难于调试的错

  • 问题内容: 我目前正在开发一个纯粹的HTML和JavaScript驱动的Web应用程序,该应用程序使用CORS来使用远程Web服务,但目前在IE 11发出GET请求时遇到了麻烦。有趣的是,我们在IE8 / 9/10中可以正常运行,而不仅仅是11。 问题是IE 11似乎超时,而不是等待服务器的响应。ajax调用很简单: 在“网络”选项卡中,使用Fiddler,我可以看到IE从不发送请求。 请问有人有

  • 问题内容: 今天,当我使用Selenium WebDrive时,出现错误。我的平台是mac osx。这是我的异常日志。 我不知道为什么会这样。我的Firefox路径是默认路径。谢谢您的帮助!! 问题答案: WebDriver使用端口7054(“锁定端口”)作为互斥体,以确保我们不会同时启动两个Firefox实例。您创建的每个新实例将在启动浏览器之前等待互斥体,然后在浏览器打开后立即释放互斥体。 因

  • 问题内容: 我仅在IE9上遇到此错误: SCRIPT575:由于错误c00c023f,无法完成操作。 错误发生在这一行: 我无法弄清楚为什么会发生这种情况,并且在其他浏览器中似乎效果很好。 这是我的JavaScript代码: 问题答案: 我不认为您的请求被中止了吗?快速谷歌搜索找到了此博客文章。尝试从XMLHttpRequest对象读取任何属性时,似乎IE9中的中止请求将给出此错误。 从帖子中,他

  • 我实际上有三个问题: Selenium WebDriver如何实现此 因为我们不能给无限睡眠的线程一个负值。 有没有更好的方法来实现无限等待? 我们在SeleniumWebDriver文档中看到了这一点