Mobile Web Application Test Automation – IV

I hope you found the first 3 parts of the blogs on Mobile Web Application Test Automation informative and helpful.
While Part 1 provides an introduction to mobile web automation, Part 2 talks about the testing methodology and how browser simulations will work and Part 3 focuses on browser simulation tools. Continuing the sequence, in Part 4, I will provide an overview of mobile web automation implementation using selenium webdriver, especially for android web browser.

Preface:

Webdriver enables you to run your tests against the browser running on a mobile device or a device emulator rather than having to use just the   desktop web browser trying to make them to behave like mobile web browser. You can run the tests against android as well as iPhone web browsers using webdriver.

Setup:

For setup, I followed the instruction provided in AndroidDriver wiki and get it worked.

How to automate:

I tried it with ISFW by setting properties for server, port and providing browser string as “androidRemoteDriver”.

selenium.server=localhost
selenium.port=4444
selenium.defaultBrowser=androidRemoteDriver

 

The easiest way over here is to record using selenium IDE and export to ISFW format. If the web application has User-Agent awareness and generates User-Agent specific content, for example google search page or gmail, then one can simulate Firefox for mobile User-Agent as described in Part 3 during recording phase.

Sample Code:

public
class AndroidDemo extends BaseTestCase {
       @Test(description = “Google search”)
       public
void tc01() {
               IsSelenium selenium = getSTB().getSelenium();
               WaitService waitService = new WaitService();

               selenium.open(“/”);

               waitService.waitForPageToLoad();

               selenium.type(“q”, “apexon test automation framework”);

               selenium.submit(“q”);

               getSTB().assertElementPresent(

                               “link=Apexon Selenium Test Automation Framework”,

                               “link Apexon Test Automation Framework”);

       }

}

 

Execution:

Before run automation, you need to execute following commands from command line to create/ start avd and install/start selenium server in avd manually as described in AndroidDriver wiki.

  1. android create avd -n my_android -t 12 -c 100M
  2. emulator -avd <avdName> -no-audio -no-boot-anim
  3. adb -e install -r <dir>/android-server*.apk
  4. adb shell am start -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity
  5. adb forward tcp:4444 tcp:8080

Here command #1 to create AVD (Android Virtual Device) requires only one time execution. Command #3 needs to be executed once or after you wipe data. Command #4 will start selenium RC in AVD from command line so you don’t need to search and start the applications in a device/emulator. Before executing command #4,   you need to wait for emulator boot status complete. Finally, run batch file to run test and that’s it…

This task can be automated using ant script including the wait for boot complete and server ready. I have also integrated it with Hudson using Android plug-in. You can find details on integration with Hudson here.

Conclusions:

  • You can test your web application with a mobile emulator or with a real device.
  • Lesser efforts are required in setting up this environment compared to desktop browser simulation approach. You can utilize the simulation approach for getting information about web elements during automation development phase or to record test using IDE.
  • It is cost effective if you run against emulator but slower compared to real device.
  • Makes it as simple as web automation for desktop browser.
  • ISFW provides strength to webdriver by fulfilling automation’s common aspects (data-driven, reporting, integration with test management tools, etc)
  • Here are some Pros & Cons of using webdriver.

Screenshots:

  1. Execution
  2. Result/Report
  3. Attached Screenshot in report

 

Interested in our Testing Services?

Please enable JavaScript in your browser to complete this form.
Checkboxes
By submitting this form, you agree that you have read and understand Apexon’s Terms and Conditions. You can opt-out of communications at any time. We respect your privacy.

Other stories you may enjoy...

One Year In: Technology Success Stories from the Pandemic

This time last year, US companies were forced to face a new and unsettling reality: business as usual was no longer an option. I wrote then about how businesses could shift their...

Healthcare Apps and the Need for Security

One of the most exciting areas in tech right now promises to be “the most personal” ever. A key aspect of making wearable devices like the Apple Watch personal is through...

Developing an App for the 2020 General Election?

Here is a thought: With the UK General Election having just finished, could the next one in 2020 be the first to use a mobile app to allow people to vote? The polling...