vendredi 25 septembre 2015

How can i check a checkbox in Selenium Webdriver with Java?

I am using Selenium in Java to test the checking of a checkbox in a webapp. Here's my code:

boolean isChecked = driver.findElement((By.xpath(xpath1))).isSelected();

But this code returns incorrect value. The checkbox in the HTML:

Active checkbox

<div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active">
<span class="ui-chkbox-icon ui-icon ui-icon-check ui-c"></span>
</div>

Inactive checkbox

<div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default">
<span class="ui-chkbox-icon ui-icon ui-c ui-icon-blank"></span>
</div>

How can I solve this problem in Selenium WebDriver with Java? Will be grateful for any help.




Aucun commentaire:

Enregistrer un commentaire