Webdriver click second element in list
selenium
Solution
There are two ways to do this: 1) Using xpath, try in following manner.
driver.findElement(By.xpath("('xpath of the link')[2]"));//If you had given html, I could have added exact xpath.
2) Using findElements() you can try following:
List<WebElement> li = driver.findElements(By.linkText("Services"));;
li.get(1).click();//If there are only two such element, here 1 is index of 2nd element in list returned.
Hope you get the idea. :)
Problem
The page I'm testing has 2 elements with the same name and I need to click the second Element. I can get the elements by using: ``` driver.findElements(By.linkText("Services")); ``` But I don't know how to `click` on the second element.