expected_conditions with Selenium in Python
<p>I want to load my driver until the text of an element become numbers:</p>

<p>here is the element:</p>

<pre><code>&lt;span id="viewed"&gt;-&lt;span&gt; or &lt;span id="viewed"&gt;&lt;span&gt;
</code></pre>

<p>it will become :</p>

<pre><code>&lt;span id="viewed"&gt;12345&lt;span&gt;
</code></pre>

<p>any solution?</p>

<p>This is untested:</p>

<pre><code>from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

ints = "012345679"

def custom_ec(driver):
    ''' Custom expected condition function to feed wait.until
    '''
    elem_text = driver.find_element_by_id("viewed").text

    # Test to see if all of the values are ints
    if all(map(lambda x: x in ints, elem_text)):
        # If all of the char in the span are ints, return the value as an int
        return int(elem_text)
    else:
        return False

driver = webdriver.Chrome()
try:
    driver.get("http://your.url/here")
    int_value = WebDriverWait(driver, 30).until(custom_ec)
finally:
    driver.quit()
</code></pre>

python selenium