WebElement radio= driver.findElement(By.xpath("//[@id=\"mydiv\"]/form/div[1]/div[3]/label"));
if (radio.isSelected()){
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id=\"mydiv\"]/form/div[1]/div[2]/label")).click();
} else {
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id=\"mydiv\"]/form/div[1]/div[3]/label")).click();
}
This is code I am using but it is always selecting the else statement even when the condition is true.