Hi everyone I am very new to selenium, just trying out one scrapper for my project. I want to select the text present in that div element which I have marked with red color. I have tried using this:
driver.find_element(
"/html/body/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div"
)
Please help me out, or suggest me a good tutorial. Thanks a lot :)
CodePudding user response:
driver.find_element_by_xpath(ELEMENT_XPATH).text
Use XPath not Full XPath
CodePudding user response:
Try to find Relative xpath. The xapth for that element would be:
//div[contains(@class,'valueValue')]
Or
//div[starts-with(@class,'valueValue')]
To extract the text from that element:
data = driver.find_element_by_xpath("//div[contains(@class,'valueValue')]")
value = data.text
# Or
value = data.get_attribute('innerText')