Android automated testing - robotium (four) CheckBox control

CheckBox control:

Click CheckBox1 to check it Click CheckBox again to uncheck it

      

Steps:

1. Click the CheckBox 1 checkbox

Validation: Return prompt: Check Box 1 is selected

2. Click the Check Box1 checkbox again (to uncheck the effect)

Validation: Back Prompt: Check Box 1 unchecked

 

  1. publicvoid testUI() throws Exception {  
  2.     this.CheckBox(); 
  3.  
  4. publicvoid CheckBox(){  
  5.     boolean expected = true
  6.     solo.clickOnButton("CheckBox"); 
  7.      
  8.     solo.clickOnCheckBox(0); 
  9.     boolean  actual = solo.searchText( "Check Box 1 is selected" ); 
  10.     assertEquals("This is not found",expected,actual); 
  11.      
  12.     solo.clickOnCheckBox(0); 
  13.     boolean  actual2 = solo.searchText( "Check Box 1 unchecked" ); 
  14.     assertEquals("This is not found",expected,actual2); 
  15.     solo.goBack(); 

 

Here solo.clickOnCheckBox(0) represents the first CheckBox element: Check Box 1

And so on, 1 represents the second CheckBox element: Check Box 2

CheckBox implementation: http://luwenjie.blog.51cto.com/925779/915848

This article is from the " Xiao Maozi " blog, please be sure to keep this source http://xiaomaozi.blog.51cto.com/925779/917073

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326395783&siteId=291194637