title: How to click on Javascript button in Selenium with no ID (Java)?
body: <p>I'm setting up a program in Java with Selenium.</p>
  
  <p>At the start of the program, a Chrome extension I'm using with the program loads up with the Chrome instance.</p>
  
  <p>Chrome then navigates to that page, selects all the boxes, and is supposed to click a button on the page that appears because of the extension.</p>
  
  <p>So I am trying to click that button, but it's a Javascript button that comes on the page through the extension. There is no ID that I can use explicitly though.</p>
  
  <p>When I inspect the element, all I see is this:</p>
  
  <pre><code>&lt;a href="javascript:void(0);" class="selected button-task" 
  style="width: 140px; margin-left: 5px; height: 23px;"&gt;
  &lt;img src="websiteimage.png here" width="20px"&gt;Selected Task&lt;/a&gt;
  </code></pre>
  
  <p>Unlike the other stuff I can click on, there is no type (checkboxes, button, etc) or a specific ID I can seek out. But it is important I click this button. What should I do? </p>
  
  <p>I get this error when I use this:</p>
  
  <pre><code>Exception in thread "main" org.openqa.selenium.InvalidSelectorException: invalid selector: 
  Unable to locate an element with the xpath expression //a[contains@class,'selected'] and contains(@class, 'repost-selected button-task') and contains(text(), 'Repost Selected') because of the following error:
  
  SyntaxError: Failed to execute 'evaluate' on 'Document': 
  The string '//a[contains@class,'selected'] and contains(@class, 'repost-selected button-task') and contains(text(), 'Repost Selected')' is not a valid XPath expression.
  </code></pre>
  
  <p>Thanks!</p>