I have this code below which seems to not go to the else if statement. It runs the first part but never seems to go to part 2, if element 1 is already selected.
Thanks
if (!driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[1]")).isSelected() ) {
driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[1]")).click();
} else if(!driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[2]")).isSelected() ) {
driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[2]")).click();
}
What I want to happen is:
If Element 1 is not selected
Click it
Else Click Element 2