title: How to construct a xpath expression with variable for Selenium in python using %s
body: <p>I am trying to use selenium to locate and select a certain element based on a variable passed into the function when it is called. I thought this would be simple enough with a good ol:</p>
  
  <pre><code>show = browser.find_element_by_xpath("//*[contains(text(), '%s')]" % eventName)
  </code></pre>
  
  <p>However, I receive error:</p>
  
  <pre><code>selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //*[contains(text(), 'VARIABLE_TEXT')] because of the following error:
  SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//*[contains(text(), 'VARIABLE_TEXT')]' is not a valid XPath expression.
  </code></pre>
  
  <p>Here is--distilled and simplified--the part of the HTML I am attempting to select:</p>
  
  <pre><code>&lt;ul&gt;
  &lt;li class="seriesElement"&gt;
  &lt;input id="productionId_0" name="productionIds" type="checkbox" value="VALUE"&gt;&lt;input type="hidden" name="_productionIds" value="on"&gt;&lt;label for="productionId_0" class="prodColor0"&gt;TEXT&lt;/label&gt;
  &lt;/li&gt;
  &lt;li class="seriesElement"&gt;
  &lt;input id="productionId_1" name="productionIds" type="checkbox" value="VALUE"&gt;&lt;input type="hidden" name="_productionIds" value="on"&gt;&lt;label for="productionId_1" class="prodColor1"&gt;TEXT&lt;/label&gt;
  &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>There are many of these list elements, and I want to select one by the text. Have I just used the wrong syntax for my xpath expression, or is this a different beast entirely?</p>