im trying to extract a true/false value which is in a tag (Mozilla Firefox). However, I cant seem to get it. I am using Selenium on Python.
I have tried to get element using two different methods:
output = driver.find_element_by_xpath('/html/body/table/tr/td[1]/span/span').get_text()
and
output = driver.find_element_by_xpath('//*[@id="prefs"]/tr/td[1]/span/span').get_text()
but it only returns Unable to locate element: /html/body/table/tr/td[1]/span/span
How can I retrieve the value? I've been scratching my head for the past few hours. TIA
CodePudding user response:
output = driver.find_element(By.XPATH,'//*[@id="prefs"]/tr/td[1]/span/span').text
If you want the text false use .text if you want the aria-hidden use .get_attribute('aria-hidden')
Switch to using By since the other method is depreciated.
Import:
from selenium.webdriver.common.by import By