Robotium : Some Useful functionalities and Methods To Make Automation Scripts More Robust
|1. Targeting Tabs In The Application
Example Case Study:
Suppose We have three tabs in a Screen/Activity in the application. named Tab1 , Tab2 , And Tab3.
And we want to navigate to Tab2 or Tab3 as by default the application launches Tab1. In this case we can manage by writing scripts like
solo.clickOnText(“Tab2”); But in reality It may click on the text ‘Tab2’ which is a part of the context of body of Tab1. So to make sure that only the link navigating to ‘Tab2’ is clicked we have to write scripts in the folowing way:
ViewGroup tabs = (ViewGroup)solo.getView(android.R.id.tabs);
View tab=tabs.getChildAt(1); //change 1 to the desired index.
solo.clickOnView(tab);
2. Targeting Hardware Menu Button and Hardware Back Button
MENU:
solo.sendKey(Solo.MENU);
BACK:
solo.sendKey(KeyEvent.KEYCODE_BACK);
3.Get Number of tabs In the current screen:
ViewGroup tabs = (ViewGroup)solo.getView(android.R.id.tabs); //Change tabs in id.tabs to the target id.
int tabcount=tabs.getChildCount();
4. Set Timeout Of various waitFor methods to your desired duration:
Timeout class facilitates to set and get Timeout details of various functions which has a default timeout duration.
e.g Timeout.setLargeTimeout(assert….//or any funtion );
Timeout.setSmallTimeout(assert….//or any funtion );Timeout.getLargeTimeout(assert….//or any funtion );
Timeout.getSmallTimeout(assert….//or any funtion );
5. Check If a button is in Enabled or Disabled State:
solo.getButton(“Clear History”).isEnabled();
Returns true if enabled otherwise false.
- Bring the auto Sync magic of Protractor to Selenium with Java - October 23, 2015
- Restarting Appium Server could improve various server freezing issues and may improve execution time - January 20, 2015
- Appium with iOS 8 and XCode 6 : What’s new? - November 5, 2014
- REST API automation testing using Apache HttpClient – The Approach - October 3, 2014
- An Overview of mobile application : Moving forward to automation - October 1, 2014
- An introduction to REST - September 29, 2014
- Run ChromeDriver with Chrome Driver Service to reduce script execution time significantly - September 26, 2014
- Selenium WebDriver – Get Cookies from an existing session and add those to a newly instantiated WebDriver browser instance. - September 26, 2014
- Simulate Copy Paste action using Java Robot and Clipboard class - September 26, 2014
- Android : How to test if Android Application has memory leaks - August 11, 2014