[Selenium Webdriver Java] display of wait synchronization

Source: Internet
Author: User

Show wait can be a custom wait condition when you perform the next operation

The wait for the display needs to be done somewhere else where synchronization is needed without affecting the script.

Selenium Webdriver provides webdriverwait and Expectedcondition classes to perform display waits

The Expectedcondition class provides a series of predefined conditions to wait for. Here are some common conditions

Pre-defined conditions Method name
Element visible clickable Elementtobeclickable (by Locator)
Element can be selected Elementtobeselected (webelement Element)
There is an element Presenceofelementlocated (by Locator)
The specified text appears in the element Texttobepresentinelement (by Locator)
The value of the element Texttobepresentinelementvalue (by locator, String text)
Title

Titlecontains (String title)

Webdriverwait calls Expectedcondition every 500 milliseconds until the correct return value is obtained. The advantage is to keep control of what is needed and where to wait, to control the waiting conditions more precisely.

1  Public voidtestwithimplicitwait () {2System.setproperty ("Webdriver.chrome.driver", "Chromedriver.exe");3Webdriver Driver =Newchromedriver ();4Driver.get ("http://map.baidu.com");5 6Webelement curcity = driver.findelement (By.id ("Curcity"));7 Curcity.click ();8     9     //set wait time 10 secondsTenwebdriverwait wait =NewWebdriverwait (driver,10); One     //wait until match element text content appears AWait.until (Expectedconditions.texttobepresentinelement (By.id ("Selcityhotcityid"), "national")); -      - driver.quit (); the}
Sample Code

[Selenium Webdriver Java] display of wait synchronization

Related Article

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.