java - Detect if radio button is checked in webdriver -
i trying validate if radio button checked. have below html code snippet radio button .
<span class="jquery-hp-radio jquery-hp-radio-checked" style="-moz-user-select: none;"> <span class="mark"> <img src="http://someurl/images/empty.gif"> </span> </span>
tried below code -
if(driver.findelement(by.classname("mark")).isselected()){ system.out.println("true"); }else { system.out.println("false"); } }
it gives output false - though radio button selected default.
i believe radio button's class
jquery-hp-radio jquery-hp-radio-checked
when checked.
so following check if button checked or not
if(driver.findelement(by.xpath("//span[@class='mark']/..")).getattribute("class").contains("checked")){ system.out.println("true"); }else { system.out.println("false"); } }