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