I have the following code line used in selenium python script:
from selenium import webdriver
driver.find_element_by_xpath(u"//span[text()='" + cat2 + "']").click()
cat2 is variable from a database list that i get like this:
db = Database()
sql = "SELECT * FROM missing
listeproduit = db.select(sql)
for record in listeproduit:
cat2 = record[6]
The probleme is when the variable contain a text like this:
cat2 = Debimetre d'air
Then the script don't works because it's an illegal xpath expression.
From my search, i understand that it's a problem with escaping the single quote in my variable cat2
From this answers :Escape single quote in XPath with Nokogiri?
They suggest to use concat() xpath function, but how to use it in my case ? Thanks for your help.
Cheers