lundi 26 janvier 2015

How to get label associated with checkbox in Selenium webdriver?


How can i print label associated with checkbox , like checkbox 1 or checkbox 2 in example below.



Checkbox Items:



<input type="checkbox" value="cb1" name="checkboxes[]">Checkbox 1
<input type="checkbox" value="cb2" name="checkboxes[]">Checkbox 2
<input type="checkbox" checked="checked" value="cb3" name="checkboxes[]">Checkbox 3


I am using below code to get the label name , but it doesn't work. getText() is also not working.


List elementList = driver.findElements(By.name("checkboxes[]"));


System.out.println("checkbox1? "+elementList.get(0).getAttribute("innerHTML"));





Aucun commentaire:

Enregistrer un commentaire