I have been struggling with this for a while now.
I have tried various was of finding the xpath for the following highlighted HTML
I am trying to grab the dollar value listed under the highlighted Strong tag.
Here is what my last attempt looks like below:
try:
price = browser.find_element_by_xpath(".//table[@role='presentation']")
price.find_element_by_xpath(".//tbody")
price.find_element_by_xpath(".//tr")
price.find_element_by_xpath(".//td[@align='right']")
price.find_element_by_xpath(".//strong")
print(price.get_attribute("text"))
except:
print("Unable to find element text")
I attempted to access the table and all nested elements but I am still unable to access the highlighted portion. Using .text and get_attribute('text') also does not work.
Is there another way of accessing the nested element? Or maybe I am not using XPath as it properly should be. I have also tried the below:
price = browser.find_element_by_xpath("/html/body/div[4]")
UPDATE: Here is the Full Code of the Site. The Site I am using here is www.concursolutions.com I am attempting to automate booking a flight using selenium. When you reach the end of the process of booking and receive the price I am unable to print out the price based on the HTML. It may have something to do with the HTML being a java script that is executed as you proceed.
Looking at the structure of the html, you could use this xpath expression:
//div[@id="gdsfarequote"]/center/table/tbody/tr[14]/td[2]/strong