Sebastian Nielsen Sebastian Nielsen - 20 days ago 11
Python Question

python selenium - webdriver wait until css_Selector visible

text = browser.find_element_by_css_selector('.dbaListing.listing.lastListing > td:nth-child(4) > span').text


This is what I want my webdriver to wait for to be located/visible.
How do I do that?

I am new to selenium, so this might be a very newbie question, but I gotta start somewhere. Please dont h8.

Thanks in advance for the help

Answer

Use WebDriverWait with the visibility_of_element_located Expected Condition:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(browser, 10)
element = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".dbaListing.listing.lastListing > td:nth-child(4) > span")))
print(element.text)