Time for action – creating an emulator - Selenium

If you do not have an Android device that you can use for testing, then you can set up an Android emulator. The emulator will then get the Selenium WebDriver APK installed and then that will control the browser on the device. Before we start, you will need to download the Android SDK from http://developer.android.com/sdk/index.html.

  1. Open up a command prompt or a terminal.

  2. Enter cd <path>/android-sdk/tools where <path> is the path to the android-sdk directory.

  3. Now enter ./android create avd -n my_android -t 14 where:

    • -n my_android gives the emulator the name my_android.
    • -t 14 tells it which version of android to use. 14 and higher is Android 4 and higher support.

  4. When prompted Do you wish to create a custom hardware profile [no], enter no.

  5. Run the emulator with:
    ./emulator -avdmy_android&
    It will take some time to come up but once it has been started, you will not have to restart unless it crashes or you purposefully close it. Once loaded you should see something like the following:

What just happened?

We have just seen what is involved in setting up the Android emulator that we can use for testing of mobile versions of our applications. As was mentioned, we need to make sure that we set up the emulator to work with Android 4.0 or later. For the emulator we need to have a target platform of 14 or later. Now that we have this done, we can have a look at installing the WebDriver Server on the device.

Installing the Selenium WebDriver Android Server

We have seen that we can access different machines and control the browsers on those machines with Selenium WebDriverRemoteDriver. We need to do the same with Android. The APK file that you downloaded earlier is the Selenium Server that is specifically designed for Android devices. It has a smaller memory footprint since mobile devices do not have the same amount of memory as your desktop machine.

We need to install this on the emulator or the physical device that you have.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Selenium Topics