Setup Instructions to Android Webdriver
Pre-Requisites:
Go to /android_sdk folder/eclipse folder
Launch Eclipse and Select a workspace location
Now navigate Windows >> Preferences >> Run/Debug >> String Substitution
Click New button to add a variable
Now open System Properties and add a variable
Pre-Requisites:
Download Android SDK
Unzip it and place it somewhere in directoryGo to /android_sdk folder/eclipse folder
Launch Eclipse and Select a workspace location
Now navigate Windows >> Preferences >> Run/Debug >> String Substitution
Click New button to add a variable
Now open System Properties and add a variable
Steps to Setup Emulator
To list all the available targets run command:
C:\>android list targets
First create the Android Virtual Device (AVD) using command:
C:\>android create avd -n my_android -t android-19 -c 100M
Now to start the emulator run command:
C:\>emulator -avd my_android &
And it will start the emulator:
Setting up Device
Either
we can use Emulator as a virtual device or can connect the actual device
through USB to your machine. We have already created an AVD named "my_android", so we will be using that one to setup and run our test case in this blog.
There are two options to run Android WebDriver Tests:
- Using the remote WebDriver Server
- Using the Android test Framework
In this blog, we will see how to run using the remote WebDriver Server:
Install the WebDriver APK
First download the WebDriver APK (Webdriver APK), and place it somewhere like in “platform-tools folder”
Every device and emulator has a serial id, to get the serial id run the following command:
C:\>adb devices
Now run the following command to install the downloaded WebDriver APK:
C:\>adb -s emulator-5554 -e install -r android-server.2.38.0.apk
When WebDriver APK is successfully installed start the Android WebDriver using the following command:
C:\>adb -s emulator-5554 shell am -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity
After running above
command Android WebDriver will be ready to use and will look like:
Now we need to setup
the port forwarding in order to forward traffic from host machine to on which
Android WebDriver will run:
C:\>adb -s emulator-5554 forward tcp:8080 tcp:8080
Now your Emulator/Device is ready to run the automation scripts.
Creation of automation script
You can simply launch Eclipse and create a Java Project to create automation scripts. Create a Java project add Selenium-Java jar files into build path.
Take a look on a simple example of searching on Google.com:
Output:
This way to use Android WebDriver has been deprecated and recommended to use Selendroid instead, but it will give basic idea to work on Android Automation. Stay tuned to see next post on Selendroid.
Facebook Page: https://www.facebook.com/crazzzygig