Introduction
The android driver allows us to execute our tests against an Android browser. This can be a simulator or a real device. This recipe will walk us through the steps we have to do to run our tests in a simulator.
Before we can register our simulator we have to download the android SDK (Software Development Kit) from the following location: SDK
Solution
We can divide this section into three parts: setup the emulator, install the WebDriver APK and finally run the test.
Setup the emulator
1) Navigate to the tools directory and create an Android Virtual Device. -n: specifies the name of the AVD -t: specifies the platform target -c: specifies the SD card storage space.
1 2 3 |
|
2) We can list the targets with the following command to check if the creation succeeded:
1 2 |
|
3)Finally we can start the emulator with the following command:
1
|
|
Install the WebDriver APK
1) We need to retrieve the serial id with the following command:
1 2 |
|
2) Download the Android server from Selenium website and save it in the platform-tools directory. To install the application enter:
1
|
|
3) Start the Android WebDriver application,by running this command:
1
|
|
4) Now we need to setup the port forwarding in order to forward traffic from the host machine to the emulator. Enter the following in the terminal :
1
|
|
Run the test
You will need to take a look in TestNG Framework
Now we have our environment setup we can run our tests. Create new TestNG and paste the code below :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
5) Run your test.
Post a Comment
Post a Comment