IE的Selenium WebDriver错误 [英] Selenium WebDriver error for IE
问题描述
我正在尝试使用Selenium Webdriver,junit和ant build自动化测试用例.自从早上以来,我收到了一些奇怪的错误.一个测试用例包含按钮单击命令.该测试在Chrome和FF上运行成功,但在IE上未成功.此前,至少有人说找不到元素X,但是有人说服务器没有提供任何信息.
I am trying to automate test cases using selenium webdriver, junit and ant build. I am getting weird errors since morning. A test case contains button click command. The test runs success on Chrome and FF but not on IE. Earlier, it was at least saying that unable to find some element X, but this one says server did not provide any information.
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)
推荐答案
在触发点击事件之前插入以下代码段
Insert following block before you fire click event
for (int second = 0;; second++) {
if (second >= 60) return "Page load failed";
try {
if (session().isTextPresent("Logoff"))
break;
}
catch (Exception e) {}
Thread.sleep(1000);
}
就我而言,我拥有测试用例的超类,这就是为什么我可以做到
In my case, I have super class for the test case, that is why I can do
session().somecommand
但是,您可以将我的解决方案转化为您的解决方案.
But, you can translate my solution into yours.
这篇关于IE的Selenium WebDriver错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!