title: Selenium Webdriver - Unable to locate element
body: <p>I have  a Selenium Webdriver JUnit Java test and I am unable to use locators successfully within a Drupal 8 table (which also has styling). In Firefox I can use Firepath and Xpath checker to determine and check the xpath OK. However when I run the JUnit 4 test it is unable to be located. What was interesting is that the first time I ran this test it worked ok, however many attempts afterwards and it will not run.</p>
  
  <p>I have used xpath etc successfully for many other tests within this web site, but for some reason I cannot get this to work.</p>
  
  <p>Actually the unable to locate element message is for the next command;</p>
  
  <pre><code>driver.findElement(By.id("edit-application-status-1")).click();
  </code></pre>
  
  <p>however I know it is failing on the previous command (as below) because it never clicks to get to this page.</p>
  
  <p>Failing code;</p>
  
  <pre><code>driver.findElement(By.xpath(".//*[@id='block-ua-theme-content']/div/div/div[2]/table/tbody/tr[1]/td[2]/a")).click();
  </code></pre>
  
  <p>also tried;</p>
  
  <pre><code>driver.findElement(By.cssSelector("a[href='/application-19']")).click();
  </code></pre>
  
  <p>I have tried changing to <code>cssSelector</code> with explict wait as below</p>
  
  <p><code>wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("a[href='/application-19']")));</code></p>
  
  <p>scroll into view as below;</p>
  
  <pre><code>WebElement element1 = driver.findElement(By.cssSelector("a[href='/application-19']"));
  jse.executeScript("arguments[0].scrollIntoView(true);", element1);
  </code></pre>