Mobile Web Application Test Automation – IV

上一篇 / 下一篇  2011-12-14 15:12:04 / 个人分类:Selenium

byChirag JayswalonSeptember 6, 2011

I hope you found the first 3 parts of the blogs onMobile Web Application Test Automationinformative and helpful.
WhilePart 1provides an introduction to mobile web automation,Part 2talks about the testing methodology and how browser simulations will work andPart 3focuses 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 inAndroidDriver wikiand get it worked.

How to automate:

I tried it withISFWby 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 inPart 3during recording phase.

Sample Code:

public
classAndroidDemoextendsBaseTestCase {
    @Test(description =“Google search”)
    public
voidtc01() {
        IsSelenium selenium =getSTB().getSelenium();
        WaitService waitService =newWaitService();

        selenium.open(“/”);

        waitService.waitForPageToLoad();

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

        selenium.submit(“q”);

        getSTB().assertElementPresent(

                “link=InfoStretch Selenium Test Automation Framework”,

                “link InfoStretch 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 inAndroidDriver 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 Hudsonhere.

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 somePros & Consof using webdriver.

Screenshots:

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

Copied fromhttp://blog.infostretch.com/mobile-web-application-test-automation-%e2%80%93-iv-4


TAG:

 

评分:0

我来说两句

Open Toolbar