You need to take care of a couple of things:
- If your usecase is to extract the value of any attribute ideally you need to use
visibility_of_element_located()
- As an alternative to text attribute you can use
get_attribute()
method.
Solution
As an alternative you can use the following Locator Strategy:
print(WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.XPATH,"//div[contains(@title,'Mytitle')]/div[1]/div[3]/span[starts-with(@id, 'infoZIndex')]"))).get_attribute("innerHTML"))
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
Update
As an alternative you can also try setting the expected_conditions
ato text_to_be_present_in_element()
as follows:
print(WebDriverWait(browser, 10).until(EC.text_to_be_present_in_element((By.XPATH,"//div[contains(@title,'Mytitle')]/div[1]/div[3]/span[starts-with(@id, 'infoZIndex')]"), "Index")).get_attribute("innerHTML"))