robotium - clicking on action bar tabs
Asked Answered
I

2

6

I'm finishing up moving to the actionbar (using actionbarsherlock), and one of the last things is to convert all the robotium integration tests. Clicking on action bar action items seems to be solved, however I cannot figure out how to click on action bar tabs with Robotium.

Incisor answered 25/9, 2012 at 21:20 Comment(0)
M
8

Action Bar Screen

you can use

[1] solo.clickOnText("TAB A"); 
    // click on action bar tab 1
    // where action bar tab 1 diaplay text = "TAB A"

[2] solo.clickOnText("TAB A"); 
    // click on action bar tab 1
    // where action bar tab 1 diaplay text = "TAB A"

if you have images in action bar tabs,

enter image description here

[1] solo.clickOnImage(0); OR solo.clickOnImageButton(0);
        // click on action bar tab 1

[2] solo.clickOnImage(1); OR solo.clickOnImageButton(1); 
        // click on action bar tab 2

i hope this will help you. Thanks.

Mimosa answered 30/9, 2012 at 2:12 Comment(2)
This approach does not work sometimes in my project, where I use the actionbarsherlock. If I run the Robotium test on a older Android version device, where the .abs actually kicks in, then Robotium is unable to click on the tabs by their texts. No problem on ICS and laterPindling
As far as I saw Android 4.0 works with the Strings as you specified them in the navigation tab, potentially containing lower case letters. Android 2.3.3. for instance requires upper case Strings ... :)Dilly
S
2

Click on action bar :-If you have the source code of the application under test, The best way is when you identify the Action Bar Item by its Id, which can be found in the R.Java of the application under test.

solo.clickOnActionBarItem(R.id.ItemToBEClicked);

Seedbed answered 5/5, 2013 at 14:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.