Wednesday, 17 July 2013

Automation of Android web app using AndroidDriver (Webdriver)

Download followings :

1. Download android sdk from http://developer.android.com/sdk/index.html
2. Download android server http://code.google.com/p/selenium/downloads/detail?name=android-server-2.21.0.apk&can=2&q=
3. Download selenium-java http://code.google.com/p/selenium/downloads/detail?name=selenium-java-2.33.0.zip&can=2&q=




We can run test web app on emulator or real device.

Follow following steps to do on emulator:

1. Set up android sdk.
2. After set up,to create an Avd .click on Sdk Manager icon
3. Go to Tools and select manage AVD.
4. Click on New button and fill avd name and all input data and click ok.
6. Now  set up android-server apk(2 nd number download) file in emulator.
7. Start the webdriver application.
8. Go to  platform-tools folder of sdk and execute following command on prompt
    adb forward tcp:8080 tcp:8080   //for communication between emulator/device to the program

Follow following steps to do on real device:

1. Connect your device to machine in debugging mode.
2. Install android-server apk file into in your mobile.
3. Start the webdriver application.
4. Go to  platform-tools folder of sdk and execute following command on prompt
    adb forward tcp:8080 tcp:8080   //for communication between emulator/device to the program


*Note: adb is android debug bridge .

Now execute following code, it will open the google page ,will type webdriver and quit.

            WebDriver driver = new AndroidDriver();
            driver.get("http://www.google.com");
            WebElement element = driver.findElement(By.name("q"));
            element.sendKeys("webdriver");
            element.submit();
            driver.quit();

Please feel free to ask any doubts.

No comments:

Post a Comment