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