Android chrome app automation using Appium

To automate the chrome browser in Android phone, you will have to start the android emulator and appium server. If emulator does not connect to internet, you will have to add the dns server as 8.8.8.8 in network settings and then restart the emulator.

If chrome does not open the url, you might have to set the chromedriver binary when starting the appium server. When I executed my code, chrome was not started because chrome version was 66 and chromedriver binary was not compatible. So I used chromedriver 2.4 and set that path when starting the appium as shown in below code.
appium --chromedriver-executable /Users/admin/chromedriver2.4
Alternatively, you can pass the executable in the capability.
caps.setCapability("chromedriverExecutable", "/Users/admin/Downloads/chromedriver77");

Before we dive into the example, let me tell you what maven dependencies, you will require to run the tests.


<dependencies>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.11</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>io.appium</groupId>
  <artifactId>java-client</artifactId>
  <version>16</version>
  <scope>test</scope>
</dependency>
</dependencies>

If you are using c#.net, You will need to download nuget package - Appium.WebDriver

Below example shows how to automate the chrome browser.


package org.softpost.android.simulator;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.ios.IOSDriver;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.net.URL;
import java.util.concurrent.TimeUnit;

/**
 * Created by Sagar on 10-07-2016.
 */
public class WebAppTest {
    WebDriver driver;
    @Test
    public void test1() throws Exception{
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("platformName", "android");

        caps.setCapability("deviceName", "Pixel 9");
       // caps.setCapability("platformVersion", "7.0.0");

        caps.setCapability(CapabilityType.BROWSER_NAME, "Chrome");
try {
    driver = new RemoteWebDriver(new URL("http://0.0.0.0:4723/wd/hub"), caps);
    driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);


    driver.get("https://www.softpost.org");

    Thread.sleep(2000);
}catch (Exception ex) {
    ex.printStackTrace();

}finally{
    driver.close();
    driver.quit();
}
    }

}

Chrome app automation using appium

Web development and Automation testing

solutions delivered!!