I have a selenium script (python) that clicks a reply button to make the class anonemail appear. The time it takes for the class anonemail to appear varies. Because of that
After click reply
button, use .visibility_of_element_located
like bellow:
browser.find_element_by_css_selector(".reply-button").click()
#wait initialize, in seconds
wait = WebDriverWait(browser, 10)
email = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, '.anonemail'))).get_attribute("value")
print(email)
Following import:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
Waits docs