Abhishek Rai
Abhishek Rai

Reputation: 2227

Using own variable in WebDriverWait. Selenium. Python

link = div.find_element_by_tag_name('a')

How can I use this in the statement

link = WebDriverWait(driver, 10).until(EC.visibility_of_element_located(div.find_element_by_tag_name('a')))

This, doesn't work.

Upvotes: 2

Views: 875

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193058

visibility_of()

visibility_of() is the expectation for checking that an element, known to be present on the DOM of a page, is visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0. element is the WebElement returns the (same) WebElement once it is visible.

selenium.webdriver.support.expected_conditions.visibility_of(element)

As visibility_of() takes an element as an argument, you can use the following Locator Strategy:

link = WebDriverWait(driver, 10).until(EC.visibility_of(div.find_element_by_tag_name('a')))

Upvotes: 2

Related Questions