Appium wait Element

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.