Wait for element to appear in Python selenium and wait for element to disappear operation

Source: Internet
Author: User
Tags xpath

In automated testing, there are times when an element of the page waits for the next action to occur, or the list appears loaded until the next step is completed, but the time is not determined, as shown in

Fortunately, after Selenium 2 there is a module expected_conditions, there are many functions to complete the work, the relevant blog is visible

Http://www.cnblogs.com/nbkhic/p/4885041.html

But in Selenium 1 or just want to write a simple usage what should I do with that? Resolved as follows:

 fromSelenium.common.exceptionsImporttimeoutexception fromSelenium.webdriver.common.byImport byImportSelenium.webdriver.support.expected_conditions as ECImportSelenium.webdriver.support.ui as UI#waits for an element to be visible, default timeout of 10 secondsdefIs_visible (Locator, timeout=10):    Try: UI. Webdriverwait (driver, timeout). Until (ec.visibility_of_element_located (By.xpath, locator) )returnTrueexcepttimeoutexception:returnFalse#waits for an element to disappear, default timeout 10 secondsdefIs_not_visible (Locator, timeout=10):    Try: UI. Webdriverwait (driver, timeout). Until_not (ec.visibility_of_element_located (By.xpath, locator) )returnTrueexcepttimeoutexception:returnFalse

The call method is simple, just need to be in time, called as follows:

Is_not_visible ('//input[@input = ' search-error')

Wait for element to appear in Python selenium and wait for element to disappear operation

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.