Eclipse 具有相同xpath的元素

Eclipse 具有相同xpath的元素,eclipse,selenium,selenium-webdriver,Eclipse,Selenium,Selenium Webdriver,我在应用程序中有3个日期日历,所有日历都具有相同的id、xpath、名称和css。我使用了选项driver.findElement(By.xpath(“/*[@id='imgIRBDate'][2]”)单击第二个元素。但它在线程“main”org.openqa.selenium.NoSuchElementException中显示异常。如何选择第二个元素?必须将完整的xpath括在括号中。请尝试以下操作: driver.findElement(By.xpath("(//*[@id='imgIRBD

我在应用程序中有3个日期日历,所有日历都具有相同的id、xpath、名称和css。我使用了选项
driver.findElement(By.xpath(“/*[@id='imgIRBDate'][2]”)
单击第二个元素。但它在线程“main”org.openqa.selenium.NoSuchElementException中显示异常。如何选择第二个元素?

必须将完整的xpath括在括号中。请尝试以下操作:

driver.findElement(By.xpath("(//*[@id='imgIRBDate'])[2]")).click();