1. Sleep () method
Thread.Sleep (60000) Force wait 60s
2, implicit waiting implicitlywait ()
Driver.manage (). Timeouts (). implicitlywait (30,timeunit.seconds);
Global wait 30s regardless of whether the element has been loaded
1) When an implicit wait is used to perform the test, if Webdriver does not find the element in the DOM, it will continue to wait for an exception that is not found when the set time is exceeded
2) In other words, when the lookup element or element does not appear immediately, the implicit wait waits for a while to find the DOM, the default time is 0
3) Once an implicit wait is set, it exists in the declaration cycle of the entire Webdriver object instance, implicitly waiting for the test to be slow for a normal response application.
4) It will wait while looking for each element, which will increase the time of the entire test execution.
The Implicitly_wait () method is more intelligent than sleep (), the latter can only choose a fixed time waiting, the former may be in a time range of intelligent waiting.
3. Display Wait webdriverwait ()
webdriverwait wait = new webdriverwait (driver, 60);
Webelement e = wait.until (new expectedcondition<webelement> () {
@Override
Public webelement apply (Webdriver D) {
Return
D.findelement (By.xpath ("//android.widget.relativelayout[@index = ' 2 ')");
}});
E.click ();
The construction method of the Webdriverwait class accepts a Webdriver object and a wait for the maximum time (60 seconds). Then call the until method, which overrides the Apply method in the Expectedcondition interface, allowing it to return a webelement, that is, loading the completed element, and then clicking. By default, webdriverwait calls Expectedcondition every 500 milliseconds until there is a successful return, which throws an exception if the specified value is not returned successfully.
Appium wait Element