title: Pass a complicated xpath through Java Script Executor in Selenium Webdriver
body: <p>I have the used the following xpath to find element on a grid.</p>
  
  <pre><code>By.xpath("//div[contains(text(),'" +EnteredCompetitionName+ "')]/preceding-   sibling::div[contains(concat(' ', @class, ' '), ' slick-cell l0 r0 ')]/a/img"
  </code></pre>
  
  <p>The problem is the grid is getting too large and the element I am trying to find cannot be found simply using find element by xpath. Hence I tried using the javascript executor in selenium webdriver. </p>
  
  <pre><code>WebElement selectedCompGlass = (WebElement) js.executeScript("return document.evaluate('//div[contains(text(),' +EnteredCompetitionName+ ')]/preceding-sibling::div[contains(concat(\' \', @class, \' \'), \' slick-cell l0 r0 \')]/a/img' ,document, null, XPathResult.ANY_TYPE, null ).singleNodeValue;");
  js.executeScript("arguments[0].click();", selectedCompGlass);
  </code></pre>
  
  <p>However, I am still getting the following error: </p>
  
  <p>missing ) after argument list Command duration or timeout: 8 milliseconds   Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'</p>