I have following code in my web page.
<div id="" class="user_acc_setails">
<ul id="accDtlUL">
<li>First Name: <span id="f_name">Anuja</span></li>
By the time page loading, the value for Sapn is not set. It will take very small time to set the value. I want to wait and get that value in my Python file.
I'm currently using following code,
element = context.browser.find_element_by_id('f_name')
assert element.text == 'Anuja'
But it gives me an AssetionError. How can I solve this?
Thanks
Correct way it this case would be to use Explicit waits (see Python code there). So you need something like
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 10)
element = wait.until(EC.text_to_be_present_in_element((By.Id,'f_name'), 'Anuja'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With