Friday, 12 July 2013

Checking and Unchecking Web Checkbox

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

  1. //Checking  
  2. public void CheckingChkbox(WebElement chkbx1){  
  3. boolean checkstatus;  
  4. checkstatus=chkbx1.isSelected();  
  5. if (checkstatus==true){  
  6. System.out.println("Checkbox is already checked");    
  7. }  
  8. else  
  9. {  
  10. chkbx1.click();  
  11. System.out.println("Checked the checkbox");  
  12. }  
  13. }  
  14.    
  15. //Unchecking   
  16. public void UnCheckingChkbox(WebElement chkbx1){  
  17. boolean checkstatus;  
  18. checkstatus=chkbx1.isSelected();  
  19. if (checkstatus==true) {  
  20. chkbx1.click();  
  21. System.out.println("Checkbox is unchecked");  
  22. }  
  23. else  
  24. {  
  25. System.out.println("Checkbox is already unchecked");   
  26. }  
  27. }  

No comments:

Post a Comment

Angular JS Protractor Installation process - Tutorial Part 1

                     Protractor, formally known as E2E testing framework, is an open source functional automation framework designed spe...