Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99416

Python & Selenium: How to wait until is text is present to continue?

$
0
0

I am trying to automate an extraction of stock prices in my broker website because yahoo and google finance have delays. But i need the code to wait for the 'home-broker' to be online so it can continue with scraping...

Here is my code:

expected = 'online'
while True:
    try:
       driver.find_element_by_xpath('//*[@id="spnStatusConexao"]').text == expected
    except NoSuchElementException:
        print('offline')
    else:
    print('online')

But, while testing it, it prints 'online' even when the homebroker displays 'offline' message.

I need to print 'offline' when the xpath text is equal to: offline . And to print 'online' when xpath text is equal to: online.


Viewing all articles
Browse latest Browse all 99416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>