1, the company's colleagues to give a global waiting to deal with,
The middle of the core of the judgment is to use the JS script to determine whether the page is refreshed, the state is complete. If yes, then execute the following script,
Otherwise, wait for the system's global wait time.
//wait for page load time Public Static voidWaitforpage (Webdriver mydriver)throwsException {expectedcondition<Boolean> expectation =NewExpectedcondition<boolean>() { PublicBoolean Apply (webdriver driver) {return( (Javascriptexecutor) driver). Executescript ("Return Document.readystate"). ToString (). Equalsignorecase ("complete"); } }; Wait<WebDriver> wait =NewWebdriverwait (Mydriver, 30);//The drive here is the drive method of the system which is passed inTry{wait.until (expectation); } Catch(Exception e) {System.out.println ("Timeout Waiting for Page Load Request to complete."); } //System.out.println ("Before sync:" + global.getdriver (). Executescript ("Return Document.readystate"). ToString ()) ; //Thread.Sleep (5000); //System.out.println ("After sync:" + global.getdriver (). Executescript ("Return Document.readystate"). toString ());Thread.Sleep (500); }
Selenium Global Wait Time processing