Get CSS selector string from WebElement in Selenium WebDriver - Java
<p>I have a WebElement and I'm simply trying to extract the CSS selector string. This is the value of the variable when I debug the code:</p>

<blockquote>
  <p>[[ChromeDriver: chrome on MAC (345345345n5435345b34)] -> css selector:
  div[class='alert alert-danger']]</p>
</blockquote>

<p>I need to have access to just the css selector: </p>

<pre><code>div[class='alert alert-danger']]
</code></pre>

<p>I could split the string, but does anyone know of a more efficient method that Selenium provides? I've tried using <code>.getAttribute("class")</code> which returns "alert alert-danger" but I need the entire selector.</p>

<p>Thank you for reading, any help would be much appreciated.</p>