title: How to locate a span with a specific text in Selenium? (Using Java)
body: <p>I'm having trouble locating a span element in Selenium using java. </p>
  
  <p>the HTML looks like:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="settings-padding"&gt;
  &lt;span&gt;Settings&lt;/span&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>And I've tried the following with no luck:</p>
  
  <pre><code>By.xpath("span[.='Settings']")
  </code></pre>
  
  <p>and</p>
  
  <pre><code>By.xpath("span[text()='Settings']")
  </code></pre>
  
  <p>and</p>
  
  <pre><code>By.cssSelector("div[class='settings-padding']"))
  </code></pre>
  
  <p>as well as some other similar attempts. Could you point me to the best method to do this? As it stands I constantly get "Unable to locate element" error in eclipse.</p>