【发布时间】:2017-03-10 11:08:29
【问题描述】:
我今天已经升级到 Selenium 3.3.0。
升级后,我的 testNG 成功执行了第一次测试。
我的第二个测试抛出了 WebDriverException
org.openqa.selenium.WebDriverException:发生未知错误 构建信息:版本:'未知',修订:'b526bd5',时间:'2017-03-07 11:11:07 -0800' 系统信息:主机:'INDH001138',ip:'10.244.44.33', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_51' 驱动信息: org.openqa.selenium.firefox.FirefoxDriver 功能 [{moz:profile=C:\Users\z019999\AppData\Local\Temp\rust_mozprofile.45imqIpOZwTh, 可旋转=false,超时={隐式=0,页面加载=300000, 脚本=30000},pageLoadStrategy=正常,平台=任何, 规范级别=0,moz:accessibilityChecks=false, acceptInsecureCerts=false,浏览器版本=52.0,平台版本=6.1, moz:processID=2808, browserName=firefox, platformName=windows_nt}] 会话 ID:f8fdc26d-26c6-40d6-b4b4-f0bb4aae087a 在 sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法) 在 sun.reflect.NativeConstructorAccessorImpl.newInstance(未知 来源)在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(未知 来源)在 java.lang.reflect.Constructor.newInstance(未知来源) 在 org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127) 在 org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93) 在 org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42) 在 org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163) 在 org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82) 在 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604) 在 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:661) 在 org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.alert(RemoteWebDriver.java:990) 在 com.myCompany.myProject.utility.SeleniumLib.isAlertPresent(SeleniumLib.java:507) 在 com.myCompany.myProject.utility.SeleniumLib.handleAlertAccept(SeleniumLib.java:424) 在 com.myCompany.myProject.utility.SeleniumLib.executeTestCase(SeleniumLib.java:613) 在 com.myCompany.myProject.testEngine.TestCaseEngine.solo(TestCaseEngine.java:132) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)在 java.lang.reflect.Method.invoke(未知来源)在 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108) 在 org.testng.internal.Invoker.invokeMethod(Invoker.java:661) 在 org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869) 在 org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193) 在 org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126) 在 org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) 在 org.testng.TestRunner.privateRun(TestRunner.java:744) 在 org.testng.TestRunner.run(TestRunner.java:602) 在 org.testng.SuiteRunner.runTest(SuiteRunner.java:380) 在 org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375) 在 org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) 在 org.testng.SuiteRunner.run(SuiteRunner.java:289) 在 org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) 在 org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) 在 org.testng.TestNG.runSuitesSequentially(TestNG.java:1301) 在 org.testng.TestNG.runSuitesLocally(TestNG.java:1226) 在 org.testng.TestNG.runSuites(TestNG.java:1144) 在 org.testng.TestNG.run(TestNG.java:1115) 在 org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132) 在 org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230) 在 org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
代码停止的地方是
private static boolean isAlertPresent()
{
try
{
driver.switchTo().alert(); // Place where my code fails
return true;
}
catch (NoAlertPresentException Ex)
{
return false;
}
}
注意:此代码适用于测试用例 1。但对于测试用例 2、3 等则失败。
【问题讨论】:
标签: java selenium exception webdriver upgrade