Reputation: 933
I have 3 date calenders in the application and all calenders are having same id, xpath, name and css. I have used the option driver.findElement(By.xpath("//*[@id='imgIRBDate'][2]")).click();
to click on the second element. But it is showing Exception in thread "main" org.openqa.selenium.NoSuchElementException. How to select the second element?
Upvotes: 0
Views: 115
Reputation: 1105
You have to enclose complete xpath in brackets. Try following:
driver.findElement(By.xpath("(//*[@id='imgIRBDate'])[2]")).click();
Upvotes: 1