Interview Questions

Selenium WebDriver - How do you verify if the checkbox/radio is checked or not ?

Selenium WebDriver Interview question and Answers


(Continued from previous question...)

Selenium WebDriver - How do you verify if the checkbox/radio is checked or not ?

We can use isSelected() method.
Syntax – driver.findElement(By.xpath("xpath of the checkbox/radio button")).isSelected(); 1
driver.findElement(By.xpath("xpath of the checkbox/radio button")).isSelected();
If the return value of this method is true then it is checked else it is not.

(Continued on next question...)

Other Interview Questions