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.
I have used xpath etc successfully for many other tests within this web site, but for some reason I cannot get this to work.
Actually the unable to locate element message is for the next command;
driver.findElement(By.id("edit-application-status-1")).click();
however I know it is failing on the previous command (as below) because it never clicks to get to this page.
Failing code;
driver.findElement(By.xpath(".//*[@id='block-ua-theme-content']/div/div/div[2]/table/tbody/tr[1]/td[2]/a")).click();
also tried;
driver.findElement(By.cssSelector("a[href='/application-19']")).click();
I have tried changing to cssSelector with explict wait as below
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("a[href='/application-19']")));
scroll into view as below;
WebElement element1 = driver.findElement(By.cssSelector("a[href='/application-19']"));
jse.executeScript("arguments[0].scrollIntoView(true);", element1);