[Selenium webdriver Java] Implicit wait-and-sync

Source: Internet
Author: User

Selenium Webdriver provides an implicit wait to synchronize the test. When an implicit wait is used to execute the test, if the Webdriver does not find the element in the DOM, it will continue to wait, after the set time is exceeded, the element exception is not found

That is, when the element does not appear immediately, the implicit wait waits for a period of time before looking for the DOM. The default time is 0.

Once an implicit wait is set, it will exist throughout the lifetime of the Webdriver object instance , and the implicit wait will slow down the test for a normal response application, waiting for each element to be searched, increasing the time of the entire test execution.

You should avoid or reduce the use of an implicit wait

Wait 60s

Driver.manage (). Timeouts (). implicitlywait (Timeunit.seconds);

Note:

Webdriver.timeouts implicitlywait (long time, java.util.concurrent.TimeUnit unit)

Specifies the wait time for driver when the found element does not appear immediately

When looking for an element, driver should poll the page until the element is found or exceeds the set time-out (before throwing a nosuchelementexception exception)

When looking for a set of elements, driver should poll the page until at least one element is found or the time-out is exceeded.

Increasing the implicit wait timeout should be used with caution because it adversely affects the execution time of the test, especially when using a slower positioning strategy such as XPath.

Parameters:

Value of time--wait time

Unit of measurement for unit--wait time

[Selenium webdriver Java] Implicit wait-and-sync

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.