Search code examples
pythonseleniumselenium-webdriverweb-scrapingwebdriverwait

python/slenium, wait till class value in html line changes


Edit: I figured it out, it would be:

wait = WebDriverWait(driver, 10)
element = wait.until(element_has_css_class((By.ID, 'mail'), "emailbox-input opentip"))

I am using selenium to create an email verifyer but I have to wait till a certain element loads, which is the input button, at the beginning its html is:

<input id="mail" type="text" onclick="select(this);" data-original-title="Your Temporary Email Address" data-placement="bottom" data-value="Loading" class="emailbox-input opentip disabledText" readonly="">

and then the class changes from class="emailbox-input opentip disabledText" to class="emailbox-input opentip":

<input id="mail" type="text" onclick="select(this);" data-original-title="Your Temporary Email Address" data-placement="bottom" data-value="Loading" class="emailbox-input opentip" readonly="">

I want the code to wait for this specific class change, how can I achieve that?

site: https://temp-mail.org/en/

Thanks!


Solution

  • Selenium sdk for python has Waits that can be used for this use case. There is even example with your specific use-case in official documentation:

    https://selenium-python.readthedocs.io/waits.html. See: Custom Wait Conditions