spinne controls:
Default display: [Selected is: Beijing]
Steps:
1. Click the [City] drop-down box
2. Select【Shanghai】
Verification: TextView Display: [Selected is: Shanghai]
- publicvoid testUI() throws Exception {
- this.Spinner();
- }
- publicvoid Spinner(){
- solo.clickOnButton("Spinner");
- boolean actual = solo.isSpinnerTextSelected(0,"北京");
- solo.pressSpinnerItem(0, 1);
- boolean actual1 = solo.searchText( "Selected is: Shanghai" );
- assertEquals("This is not found",true, actual1);
- }
isSpinnerTextSelected has two parameters
public boolean isSpinnerTextSelected(int index, String text)
index: locate the selected Spinner, the first one is 0
text: the text that exists for the selected Spinner
What this API returns is a boolean value that returns true when the condition is met
pressSpinnerItem has two parameters
public void pressSpinnerItem(int spinnerIndex, int itemIndex)
spinnerIndex: locate the Spinner to be used, the first one is 0
intemIndex: locate the drop-down item to be pressed, as shown in the figure: Beijing=0 Shanghai=1 Tianjin=2 ....
Spinner implementation: http://luwenjie.blog.51cto.com/925779/917238
This article is from the " Xiao Maozi " blog, please be sure to keep this source http://xiaomaozi.blog.51cto.com/925779/917287