Monday, October 24, 2011

Checking and Unchecking Web Checkbox

We can use the below methods to check or uncheck web checkbox.


//Checking
public void CheckingChkbox(WebElement chkbx1){
boolean checkstatus;
checkstatus=chkbx1.isSelected();
if (checkstatus==true){
System.out.println("Checkbox is already checked");
}
else
{
chkbx1.click();
System.out.println("Checked the checkbox");
}
}

//Unchecking
public void UnCheckingChkbox(WebElement chkbx1){
boolean checkstatus;
checkstatus=chkbx1.isSelected();
if (checkstatus==true) {
chkbx1.click();
System.out.println("Checkbox is unchecked");
}
else
{
System.out.println("Checkbox is already unchecked");
}
}

1 comment:

  1. I simply want to mention I’m newbie to blogging and certainly savored your web page. Almost certainly I’m want to bookmark your website . You really have amazing articles and reviews. Thanks for sharing your web page.

    Jorcel
    www.imarksweb.org


    ReplyDelete