I am testing a Hybrid Android app - Tubemate in Appium.

I'm using the following configuration:

  1. selenium-java = version 3.0.1
  2. appium java-client = version 4.1.2
  3. chromedriver = version 2.19
  4. Android = 6.0.1 Marshmallow
  5. Chrome Webview = version 44.0.2403.119

Everything is the latest version from mvn repository.

The following Java Code is used.

package tk.sathyacse67.tcs;

import org.testng.annotations.Test;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;

import org.testng.annotations.BeforeMethod;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterMethod;

public class HybridTest {
    AppiumDriver driver;

    public void beforeMethod() throws MalformedURLException {
        DesiredCapabilities android_dcb = new DesiredCapabilities();
        android_dcb.setCapability("platformName", "Android");
        android_dcb.setCapability("platformVersion", "6.0.1");
        android_dcb.setCapability("deviceName", "device");
        android_dcb.setCapability("appPackage", "devian.tubemate.home");
        android_dcb.setCapability("appActivity", "devian.tubemate.home.TubeMate");

        driver = new AndroidDriver(new URL(""), android_dcb);

    public void f() throws InterruptedException, MalformedURLException {
        WebDriverWait wait = new WebDriverWait(driver, 30);

        List<AndroidElement> a=driver.findElements(By.id("devian.tubemate.home:id/title"));



    public void afterMethod() {

But whenever I change my context from NATIVE_APP to WEBVIEW, it doesn't succeed always. Most of the time, Appium gets stuck at this stage.

> info: [debug] returning process name: devian.tubemate.home
> info: [debug] Available contexts: 
> info: [debug] ["WEBVIEW_devian.tubemate.home"]
> info: [debug] Available contexts: NATIVE_APP,WEBVIEW_devian.tubemate.home
> info: [debug] Connecting to chrome-backed webview
> info: Chromedriver: Changed state to 'starting'
> info: Chromedriver: Set chromedriver binary as: C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe
> info: Chromedriver: Killing any old chromedrivers, running: FOR /F "usebackq tokens=5" %a in (`netstat -nao ^| findstr /R /C:"9515 "`) do (FOR /F "usebackq" %b in (`TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe`) do (IF NOT %b=="" TASKKILL /F /PID %a))
> info: Chromedriver: No old chromedrivers seemed to exist
> info: Chromedriver: Spawning chromedriver with: C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe --url-base=wd/hub --port=9515
> info: Chromedriver: [STDOUT] Starting ChromeDriver 2.19.346078 (6f1f0cde889532d48ce8242342d0b84f94b114a1) on port 9515
> Only local connections are allowed.
> info: JSONWP Proxy: Proxying [GET /status] to [GET] with no body
> info: JSONWP Proxy: Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"10.0\"}}}"
> info: JSONWP Proxy: Proxying [POST /session] to [POST] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"devian.tubemate.home","androidUseRunningApp":true,"androidDeviceSerial":"EBAZFG563168"}}}

After sometime holding at that stage, it says the following and quit.

> info: [debug] Didn't get a new command in 60 secs, shutting down...
> info: Shutting down appium session
> info: [debug] Pressing the HOME button
> info: [debug] executing cmd: D:\tools_r25.2.3-windows\platform-tools\adb.exe -s EBAZFG563168 shell "input keyevent 3"
> info: [debug] Stopping logcat capture
> info: [debug] Logcat terminated with code null, signal SIGTERM
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
> info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
> info: [debug] [BOOTSTRAP] [debug] Closed client connection

What would be possible workaround?

  • I have already answered the similar problem here. You can refer this.
    – Vinod
    Feb 1, 2017 at 13:12

1 Answer 1


You don't need to switch, try capturing the screen using UIAutomatorViewer 2-3 times, it will work for sure

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.