2
votes

I'm using Selenium for Python 3.x and Chrome webdriver. I would like to locate a price element using XPATH expression. HTML looks:

enter image description here

My XPATH to this element looks in this way and is valid:

//td[contains(text(), 'Montant')]/following-sibling::td/span

I can find element by this XPATH in console by

$x("//td[contains(text(), 'Montant')]/following-sibling::td/span")

ChroPath plugin and XPath helper plugin shows this XPATH as valid too. But when I run the test I get this error:

selenium.common.exceptions.WebDriverException: Message: unknown error: Unsupported locator strategy: //td[contains(text(), 'Sous total')]/following-sibling::td/span (Session info: chrome=78.0.3904.108) (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Linux 4.15.0-70-generic x86_64)

I don't know why this XPATH generates this error and how I can fix this. Additionally, another XPATH axes don't generate the problems.

1
Did you check version incompatibility? See stackoverflow.com/questions/56491606/… - Alejandro
update chromedriver version to compatible with chrome browser version - Nik
What code are you using to find the element? The issue might be with the way you are calling driver.FindElement, and not have anything to do with the XPath. - Christine

1 Answers

0
votes

Is this working ?

'//td[contains(text(), 'Montant')]/../td[2]/span'