Skip to main content
How to Carry out Web Testing on Android with Appium
Last Updated May 19, 2020 — Continuous Testing Expert

How to Carry out Web Testing on Android with Appium

From Selenium to Appium:
Mobile testing made easy for web testers

This webinar provides the principles of testing mobile apps for audiences who are already familiar with Selenium. This is the perfect session for people already working with Selenium who would like to get a deep knowledge of Appium.

Watch now
Continuous Testing

Introduction Appium Simple Web test creation and execution Executing the Test Prerequisites Start Appium Server Create Run Configuration in IntelliJ Execute the Run Configuration


With the advent of Smartphones, Enterprises have to cater their applications to Mobile devices in addition to web testing for desktop Computers.

Typically, Native applications are built for Mobile devices, but this is not enough. The reason is there are Customers who do not wish to install native applications due to reasons like,

  • Space restrictions.
  • A quick review of the product does not require installation of Native applications.
  • Avoid Native application notification affecting the speed of the mobile device.

Hence it is important that Web Applications which are lighter and require no additional installations to be also receptive to Mobile browsers. This also means that the testing now requires for supportability of these applications in Mobile browsers. Android

This article focuses on Web Testing on Mobile devices using the Android Operating System

There are several tools available which support Web Testing in Android and few of them are,

  1. Appium
  2. Selendroid
  3. Espresso Web
  4. Robitium


The table below summarizes how Appium compares with other tools on Automation testing.

[table id=61 /]

We can see that Appium has more advantages than its peers with broader language support, larger developer community, and cross-platform being important ones.

The rest of the article will focus on a short tutorial on how to develop a simple Web test in Appium.

Simple Web test creation and execution

Creating the Web Test using Appium

We will use Java as a programming language and IntelliJ IDE in these instructions.

Step 1. Create a Gradle Project in IntelliJ

Specify the name of the Gradle project.

In the rest of the screens, choose defaults and click next and in the final step finish to create the project.

Step 2. Specify the dependencies in build.gradle file.

Open the build.gradle file and replace existing ‘dependencies' directives following lines.

[java] dependencies { compile group: 'org.testng', name: 'testng', version: '+' compile group: 'io.appium', name: 'java-client', version: '+' } [/java]

Save the project and click ‘Import changes' alert popped up by IntelliJ.

This will download all the dependencies.

Step 3. Create a Java file and Implement the Test.

Select the project's Java folder and create the Java class named AppiumWebTest.

Now we start creating the Test using the TestNG framework, below are important.

Initializing the driver

Appium requires the initializing of WebDriver to connect the Appium Server/Devices. In general, initialization needs to be accomplished by passing the Desired capabilities.  Desired capabilities define session attributes. Typically these form the initialization for the Test class and need to be in the initialization function of the Test framework.

Note: deviceName can be found out by executing command ADB devices. More information on this can be found in Enabling Developer Mode.

[java] DesiredCapabilities dc = new DesiredCapabilities(); protected RemoteWebDriver driver = null; . . dc.setCapability("platformName","Android"); dc.setCapability("deviceName", DEVICE_NAME); dc.setCapability(, "Chrome"); dc.setCapability("chromedriverExecutable","CHROME_DRIVER_PATH"); driver = new AndroidDriver(new URL(APPIUM_SRV_URL), dc); [/java]

In the above capabilities, browserName and chromedriverExecutable are specifically used in Web Testing context.

[table id=62 /]

Note: In order to automate any browser, Appium needs a browser driver. Please refer to the documentation Appium automating of mobile web apps.

Test Method

Test function in the context of Mobile Web testing involved primarily, loading the Web application, locating the UI elements, and executing the automation commands.

[java] @Test public void testWeb() { // loading web url driver.get(""); // locating element. By qBy = By.xpath("//*[@name='q']"); // click and sendkeys automation commands driver.findElement(qBy).click(); driver.findElement(qBy).sendKeys("experitest"); driver.findElement(qBy).sendKeys(Keys.ENTER); } [/java]

Releasing the driver

[java] @AfterTest public void tearDown() throws MalformedURLException { driver.quit(); } [/java]

The final test will look like this,

[java] import io.appium.java_client.MobileElement; import; import; import io.appium.java_client.remote.MobileCapabilityType; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import; import; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; /** * Class for Web Testing using Appium in an Android Device. */ public class AppiumTest { DesiredCapabilities dc = new DesiredCapabilities(); protected RemoteWebDriver driver = null; public static final String APPIUM_SRV_URL = "http://localhost:4723/wd/hub"; public static final String DEVICE_NAME = "a3ae1c63"; public static final String CHROME_DRIVER_PATH = "C:\\experitest1\\chromedriver_win32\\chromedriver.exe"; @BeforeTest public void setUp() throws MalformedURLException { dc.setCapability("platformName","Android"); dc.setCapability("deviceName", DEVICE_NAME); dc.setCapability("browserName", "Chrome"); dc.setCapability("chromedriverExecutable","CHROME_DRIVER_PATH"); driver = new AndroidDriver(new URL(APPIUM_SRV_URL), dc); } @Test public void testWeb() { driver.get(""); By qBy = By.xpath("//*[@name='q']"); driver.findElement(qBy).click(); driver.findElement(qBy).sendKeys("experitest"); driver.findElement(qBy).sendKeys(Keys.ENTER); } @AfterTest public void tearDown() throws MalformedURLException { driver.quit(); } } [/java]

The example project associated with this blog is located at First Web Test using Appium.

Executing Web Testing


  1. The latest version of Java, needed for Android Studio.
  2. Installation of Android Studio with SDK. This is needed since adb gets installed as part of the Android SDK. The adb utility is required to get the device list connected to the PC.
  3. Installation of the latest version of IntelliJ.
  4. Connecting the Mobile device to the PC using USB cable and enabling the developer mode/USB debugging in the android device.
  5. Installation of Appium Desktop.

Start Appium Server

Start the Appium Server by launching Appium Desktop and then clicking the Start Server button.

appium sign in web testing

Create Run Configuration in IntelliJ

To create a Run Configuration file navigate to IntelliJ Menu > Run > Edit Configurations. This will open up a dialog box. Click on +, Specify a name in the ‘Name' field. Select the class name in the Class field and Click OK to save.

appium web testing testng

Execute the Run Configuration

appium web testing

Execute the test by executing the Run Configuration created above by navigating to Run > Run Configuration name (AppWebTestTestNG)

Guy Arieli - CTO


More from the Blog

View more
May 13, 2022

What tips would you give testers on how to ask better questions?

Continuous Testing
The nature of testing is not about confirmation. It is about questioni ...
Read More
Mar 23, 2022 Continuous Testing, First in Market to Support Android 13 DP

Continuous Testing is proud to announce that our Continuous Testing solution i ...
Read More
Mar 21, 2022

Eliminate inefficiencies in your enterprise with codeless and continuous automated testing

Continuous Testing
Today, terms like codeless, continuous automated testing and shift lef ...
Read More
Feb 07, 2022

These key factors will help you choose an automation tool

Continuous Testing
The year 2022 looks to be another banner year of growth in the softwar ...
Read More
Contact Us