0

I am clicking on image button, but getting error as:

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element

Html:

<img src="../RupeeWeb/images/entry/trade_jm.png" style="width: 25px; margin-bottom: -1px;"/>

My code is:

driver.findElement(By.xpath("//*[@id=\"1556776066373-0-uiGrid-002G-cell\"]/a[1]/img")).click();

Error:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element:
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

I think there must be problem of Wait. Try the code to wait for that particular element.

WabDriverWait wait = new WebDriverWait(driver,20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\"1556776066373-0-uiGrid-002G-cell\"]/a[1]/img")));
driver.findElement(By.xpath("//*[@id=\"1556776066373-0-uiGrid-002G-cell\"]/a[1]/img")).click();
sp324
  • 285
  • 2
  • 20