Selenium: test if element contains some text
It is possible to do in selenium IDE but I don't know how to do it with python and selenium.
I want to set a waiting that wait until that element contains part of the specified text. Thanks.
Selenium: test if element contains some text
It is possible to do in selenium IDE but I don't know how to do it with python and selenium.
I want to set a waiting that wait until that element contains part of the specified text. Thanks.
You can wait for element like this :
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 10)
element = wait.until(EC.visibility_of_element_located((By.ID, 'someid')))
extract the text like this :
actual_text = element.text
check whether it contains expected text or not like this:
self.assertIn('expected_string_here', actual_text)
or like this :
print expected_string_here == actual_text
Yes, you can use this:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(self.driver, 30).until(
EC.text_to_be_present_in_element(By.ID, 'your_element_id', "The_text_you_are_looking_for"))
The element can be located by class name, css_selector, xpath etc.
The By.ID
and the element locator should be updated accordingly