按钮点击页面后刷新并重定向到另一个页面。在我的情况下按钮点击后我给了页面刷新超时但按钮点击后显示超时异常没有时间等待。我使用了所有类型的时间等待事件我使用了线程.sleep()但没有用。
例外:
失败:createEventTest org.openqa.selenium.TimeoutException:等待页面加载超时。 命令持续时间或超时:15.08秒 构建信息:版本:' 2.53.0',修订版:' 35ae25b1534ae328c771e0856c93e187490ca824',时间:' 2016-03-15 10:43:46' 系统信息:主机:' pc',ip:' 192.168.1.6',os.name:' Windows 8.1',os.arch:&#39 ; amd64',os.version:' 6.3',java.version:' 1.7.0_79' 会议ID:a29803a6-5ec1-4791-b26f-3ab0adb47c7b 驱动程序信息:org.openqa.selenium.firefox.FirefoxDriver Capabilities [{platform = WINDOWS,acceptSslCerts = true,javascriptEnabled = true,cssSelectorsEnabled = true,databaseEnabled = true,browserName = firefox,handlesAlerts = true,nativeEvents = false,webStorageEnabled = true,rotating = false,locationContextEnabled = true,applicationCacheEnabled = true ,takeScreenshot = true,version = 46.0.1}] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) 在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) 在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) 在org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327) 在org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) 在org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:51) 在com.sun.proxy。$ Proxy6.click(未知来源) 在com.pv.pages.CreateEventPage.createApprovedEvent(CreateEventPage.java:356) 在com.pv.pages.CreateEventPage.createEvent(CreateEventPage.java:688) 在com.pv.tests.CreateEventTests.createEventTest(CreateEventTests.java:39) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86) 在org.testng.internal.Invoker.invokeMethod(Invoker.java:643) 在org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) 在org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) 在org.testng.TestRunner.privateRun(TestRunner.java:782) 在org.testng.TestRunner.run(TestRunner.java:632) 在org.testng.SuiteRunner.runTest(SuiteRunner.java:366) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361) 在org.testng.SuiteRunner.privateRun(SuiteRunner.java:319) 在org.testng.SuiteRunner.run(SuiteRunner.java:268) 在org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) 在org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1246) 在org.testng.TestNG.runSuitesLocally(TestNG.java:1171) 在org.testng.TestNG.run(TestNG.java:1066) 在org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:113) 在org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:206) 在org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:177) 引起:org.openqa.selenium.TimeoutException:等待页面加载超时。 构建信息:版本:' 2.53.0',修订版:' 35ae25b1534ae328c771e0856c93e187490ca824',时间:' 2016-03-15 10:43:46' 系统信息:主机:' pc',ip:' 192.168.1.6',os.name:' Windows 8.1',os.arch:&#39 ; amd64',os.version:' 6.3',java.version:' 1.7.0_79' 驱动程序信息:driver.version:未知 at .Utils.installClickListener / e<(file:/// C:/Users/fu/AppData/Local/Temp/anonymous7103862578695056607webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:9372) at .WebLoadingListener / e(file:/// C:/Users/fu/AppData/Local/Temp/anonymous7103862578695056607webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:5142) at .WebLoadingListener /<(file:/// C:/Users/fu/AppData/Local/Temp/anonymous7103862578695056607webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:5150) at .fxdriver.Timer.prototype.setTimeout /< .notify(file:/// C:/Users/fu/AppData/Local/Temp/anonymous7103862578695056607webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor的.js:625)
答案 0 :(得分:0)
试过这个?
$pdo
答案 1 :(得分:0)
我曾经使用javascript进行页面加载。现在我的代码运行正常。
public static void waitForPageToLoad() {
do {
js = (JavascriptExecutor) driver;
pageLoadStatus = (String)js.executeScript("return document.readyState");
System.out.print(".");
} while ( !pageLoadStatus.equals("complete") );
System.out.println();
System.out.println("Page Loaded.");
}