Things Robotium Can Do that Selendroid Can’t
What makes Robotium and Selendroid different? Find out in this post, which explains the things Robotium can do that Selendroid can’t when it comes to mobile testing.
Robotium vs. Selendroid: Quick Overview
Robotium is an extension of the Android testing framework. It allows you to write automated tests for native and hybrid Android apps. It was designed from the beginning with mobile in mind.
In contrast, Selendroid is based on Selenium, a framework designed to automate web browser testing. By itself, Selenium cannot be used to test mobile apps. It can only test mobile websites. Selendroid was adapted from Selenium to address this challenge and enable mobile testing using a Selenium-based framework.
So, what are the differences between these two frameworks? How can you choose whether to use Selendroid or Robotium to test Android apps? Keep reading for an overview of the main differences.
Since Selendroid is based on the Selenium framework, it reuses the existing Selenium infrastructure for web testing, and implements JSON wire protocol to interact with AUT. The main idea is that testing identifies different UI elements on the application page (buttons, text fields, lists, and so on) and interacts with them by sending different keys to the identified elements. It treats all the UI elements equally and doesn’t reflect specific functionality. It can open the menu, press the Android home button, simulate gestures (single tap, double tap, long press, etc).
Robotium takes a different approach. Since it was built specifically to test Android apps, it takes into full consideration the architecture and nature of Android apps. It extends the Android test framework. It has full support for Views, WebViews, Activities, Dialogs and Context Menus. It can be used with other Android test classes such as ActivityInstrumentationTestCase2.
Higher Level of Abstraction
Selendroid recognizes UI elements according to different locators, and performs clicks on these objects. A Selendroid test case will look something like this:
//clear login text field driver.findElement(By.id(R.id.username)).clear(); //enter user name driver.findElement(By.id(R.id.username)).sendKeys("admin"); //clear password text field driver.findElement(By.id(R.id.passwd)).clear(); //enter password driver.findElement(By.id(R.id.passwd).sendKeys("admin"); //click submit button driver.findElement(By.id(R.id.submitButton)).click();
Robotium recognizes UI elements by their internal application IDS runtime binding to UI components. It makes test cases more robust.
Full support on the UI component level means Robotium has a specific set of functions for each UI element. The same fragment of code in Robotium will be more readable and more recognizable for Android developers:
//clear login text field solo.clearEditText(R.id.username); //enter user name solo.enterText(R.id.username, "admin"); //clear password text field solo.clearEditText(R.id.passwd); //enter password solo.enterText(R.id.passwd, "admin"); //submit solo.clickOnButton(R.id.submitButton);
One of the main components of the Android architecture is an activity. An activity represents a single screen with a user interface. Any Android app consists of multiple activities.
Robotium’s full support for activities allows spanning of multiple Android activities. Robotium provides a set of functions to test and manipulate activities:
- ...and more.
This feature is very powerful since it reflects the Android architecture and allows you to test activities separately. One can view it as a unit test for activities.
Selendroid offers the following APIs to test gestures:
Robotium gesture support is much wider. It supports:
- Different types of clicks (click, press, etc.) for different UI elements—clickInList, clickInRecyclerView, clickButton, clickLongOnTextAndPress, pressMenuItem etc.
- go back;
- pinch to zoom;
- Different types of scroll for different UI elements—scrollDown, scrollToBottom, scrollDwonList, scrollToSide;
Device manipulation support
Robotium provides a set of APIs to manipulate the mobile device during testing:
- turn on/off WiFi;
- turn on/off mobile data;
- set device orientation;
- unlock device screen;
- manipulate soft keyboard;
- monitor memory usage (asserMemoryNotLow function).
A mobile application behavior could be affected significantly by changing network connectivity settings, device orientation, and memory consumption. Therefore, this set of APIs is extremely important to ensure correct application behavior.
Android IDE integration
Robotium is fully integrated with Android Studio and Eclipse, the primary Android development environments. It makes it easier for Android developers to set up and use the testing environment.
Robotium scripts can be recorded, which shortens test development time significantly. However, Robotium’s Recorder is not an open source tool. It’s a plugin that requires a paid license for Android Studio and Eclipse.
Both Robotium and Selendroid are great and powerful tools for Android testing. If you have to choose, it really comes down to the tester’s skill set.
If a tester is highly experienced in Selenium, it would be really easy to jump to Android testing using Selendroid.
For people with a background in native Android development, Robotium would be a more natural choice. It is based on the same building blocks as native Android applications, and utilizes the same concepts. It also provides better support for the use of device capabilities.
Join us at SauceCon 2017 in San Francisco from June 6-8, the first-ever Sauce Labs user conference. A three-day event filled with training, workshops, best practices, and visionary content from the leading minds in automated testing. Tickets are still available.
Nadia Minaev is a software engineer with deep knowledge in a wide variety of modern technologies. Throughout her career she has worked for such well-known technology leaders as HP, Intel, and others. Nadia founded Alkon Technologies, a software development company, and developed FarmGalaxy, a mobile app that connects local farmers to their customers.
- Accessibility Testing
- Appium Resources
- Best Practices
- Continuous Delivery
- Continuous Integration
- Continuous Testing
- Cross Browser Testing
- Guest Blog Posts
- Load Testing
- Mobile Development & Testing
- News & Product Updates
- Open Sauce
- Open Source
- Performance Testing
- Product Updates
- Quality Assurance
- Quality Engineering
- Sauce Product Info
- Security Testing
- Selenium Resources
- Software Development & Testing
- The Story of Sauce