Option 1:
You can use XPath indexing.
Example:
driver.findElement(By.xpath("(//*[@id="notificationStatusSwitch"])[2]"));
Option 2:
You can use findElements(): Using the given “locating mechanism” find all the elements on the current page.It returns a list of web elements, Then access the second one found
Example:
List<WebElement> elementList = driver.findElements(By.xpath("//*[@id="notificationStatusSwitch"]"));
elementList.get(1).click;
You can use XPath indexing.
Example:
driver.findElement(By.xpath("(//*[@id="notificationStatusSwitch"])[2]"));
Option 2:
You can use findElements(): Using the given “locating mechanism” find all the elements on the current page.It returns a list of web elements, Then access the second one found
Example:
List<WebElement> elementList = driver.findElements(By.xpath("//*[@id="notificationStatusSwitch"]"));
elementList.get(1).click;