Hybrid Android App testing. Can't switch to WEBVIEW

Hello,

I am trying to do automated testing. I am using linux RH.

My code:

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;

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

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;

public class MyApp {

AndroidDriver<WebElement> driver;
ChromeDriver webDriver;

@Test
public void MyAppTest () throws MalformedURLException, InterruptedException { 		
	DesiredCapabilities capability = new DesiredCapabilities();
	capability.setCapability("deviceName", "GalaxyNexus");
	capability.setCapability("platformName", "Android");
	capability.setCapability("platformVersion", "4.4.2");
	capability.setCapability("appPackage","com.MyApp");
	capability.setCapability("appActivity","MyApp");
	capability.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 15);	
	
	driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capability);
	
}	

@Test
public void findButton() throws MalformedURLException {
					
	DesiredCapabilities capabilities = DesiredCapabilities.chrome();
	ChromeOptions options = new ChromeOptions();
	capabilities.setCapability("chrome.binary", "/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64");
	capabilities.setCapability(ChromeOptions.CAPABILITY, options);
	webDriver = new ChromeDriver(capabilities);
	
	WebView.setWebContentsDebuggingEnabled(true);
	
	//driver.context("NATIVE_APP"); // set context to NATIVE
	driver.context("WEBVIEW_MyApp"); // set context to WEBVIEW
	
	driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
	driver.findElement(By.xpath("/html/body/div[5]/div/div/div[1]/div[1]/div[3]/div[1]/div[2]/div[1]/a"));
} 

}

When I run this test , get this error saying that webDriver = new ChromeDriver(capabilities) line is incorrect. If I dismiss this line I get this error:

Chromedriver: Set chromedriver binary as: /home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64
info: Chromedriver: Killing any old chromedrivers, running: ps -ef | grep /home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64 | grep -v grep |grep -e '--port=9515\(\s.*\)\?$' | awk '{ print $2 }' | xargs kill -15
info: Chromedriver: No old chromedrivers seemed to exist
info: Chromedriver: Spawning chromedriver with: /home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64 --url-base=wd/hub --port=9515
info: Chromedriver: [STDERR] /home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64)
error: Chromedriver: Chromedriver exited unexpectedly with code 1, signal null

I would appreciate any help.

When you say WebView, do you mean to say WebView with in native app, which loads the url. Its not a separate page loaded on mobile browser.

If its native webview, you need the following -

  1. You application code should have set - WebView.setWebContentsDebuggingEnabled(true);
  2. You create simple Android driver. You do not create separate Chrome Driver.
  3. Whenever you see a Webview loaded, you change the context. You can check if the webview is loaded using below code -

Check if view is webview -

protected boolean isWebView() {
boolean bWebView = false;
android_driver.context("NATIVE_APP");
try {
	Thread.sleep(3000);
} catch (InterruptedException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
List<WebElement> mList = android_driver
		.findElementsByClassName("android.webkit.WebView");
if (mList.size() > 0) {
	System.out.println("Webview available");
	android_driver.context("WEBVIEW_com.xxx.yyy.mobile");
	bWebView = true;
} else {
	System.out.println("Webview NOT available");
	// android_driver.context("NATIVE_APP");
}

return bWebView;

}

@RamS My application is hybrid, not native. It stands as web application and as application on the phone. It is built using Worklight. I set already WebView.setWebContentsDebuggingEnabled(true) but it does not help. When I run my code, I got message which says:

Set chromedriver binary as: /home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64

I added your code, but it do not print out any message.

When I use my code I get such information:

Available contexts: NATIVE_APP,WEBVIEW_MyApp
info: [debug] Connecting to chrome-backed webview
info: Chromedriver: Set chromedriver binary as: /home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64

Also, I am using Firefox, not chrome. May it result tests?

Still no answer… Do appium requires installed chromedriver to run tests?

Try using this on your code :

 Set<String> contextNames = driver.getContextHandles();
     for (String contextName : contextNames) {
       System.out.println(contextName);
       if (contextName.contains("WEBVIEW")){
         driver.context(contextName);
     	Thread.sleep(15000);
       }

If it does not work, paste the entire appium log and java logs

I still get error…
My java logs:

public class MyApp {

private static AppiumDriver<WebElement> driver;


@Test
public void MyAppTest () throws MalformedURLException, InterruptedException { 	
	
	DesiredCapabilities capability = new DesiredCapabilities();
	capability.setCapability("appium-version", "1.4.7");
	capability.setCapability("deviceName", "GalaxyNexus");
	capability.setCapability("platformName", "Android");
	capability.setCapability("platformVersion", "4.4.2");
	capability.setCapability("appPackage","com.My_App");
	capability.setCapability("appActivity","My_App");
	capability.setCapability("autoWebview", true);
	capability.setCapability("automationName","appium");
	capability.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 15);
	
	WebView.setWebContentsDebuggingEnabled(true);
	
	System.setProperty("webdriver.chrome.driver", "/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64");
	
	driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capability);
	
	WebView.setWebContentsDebuggingEnabled(true);
	
	Set<String> contextNames = driver.getContextHandles();
     for (String contextName : contextNames) {
       System.out.println(contextName);
       if (contextName.contains("WEBVIEW")){
         driver.context(contextName);
     	Thread.sleep(15000);
       };
     }
	
	driver.quit();
	
	driver.findElement(By.xpath("/html/body/div[5]/div/div/div[1]/div[1]/div[3]/div[1]/div[2]/div[1]/a"));
	
	driver.quit();

	
     }
	
}

Appium log:

info: [debug] Getting a list of available webviews
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "cat /proc/net/unix"
info: [debug] WEBVIEW_2838 mapped to pid 2838
info: [debug] Getting process name for webview
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "ps"
info: [debug] Parsed pid: 2838 pkg: My_App
info: [debug] from: u0_a57,2838,936,772124,99368,ffffffff,b77028b5,S,com.My_App
info: [debug] returning process name: My_App
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_My_App
info: [debug] ["WEBVIEW_MyApp"]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_My_App
info: [debug] Connecting to chrome-backed webview
info: Chromedriver: Set chromedriver binary as: /home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64
info: Chromedriver: Killing any old chromedrivers, running: ps -ef | grep /home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64 | grep -v grep |grep -e '--port=9515\(\s.*\)\?$' | awk '{ print $2 }' | xargs kill -15
info: Chromedriver: No old chromedrivers seemed to exist
info: Chromedriver: Spawning chromedriver with: /home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64 --url-base=wd/hub --port=9515
info: Chromedriver: [STDERR] /home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64)
error: Chromedriver: Chromedriver exited unexpectedly with code 1, signal null
warn: Chromedriver for context WEBVIEW_My_App stopped unexpectedly
warn: Chromedriver quit unexpectedly, but it wasn't the active context, ignoring

I am running test using TestNG. May it be a problem?

If i delete manually chromedriver, I get this:

    Connecting to chrome-backed webview
info: <-- POST /wd/hub/session - - ms - - 
info: --> POST /wd/hub/session {"desiredCapabilities":{"automationName":"appium","newCommandTimeout":15,"platformVersion":"4.4.2","autoWebview":true,"deviceName":"GalaxyNexus","platformName":"Android","appActivity":".My_App","appium-version":"1.4.7","appPackage":"My_App"}}
info: Client User-Agent string: Apache-HttpClient/4.4.1 (Java/1.7.0)
error: Failed to start an Appium session, err was: Error: Requested a new session but one was in progress
info: [debug] Error: Requested a new session but one was in progress
    at [object Object].Appium.start (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/lib/appium.js:139:15)
    at exports.createSession (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/lib/server/controller.js:188:16)
    at Layer.handle [as handle_request] (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/layer.js:82:5)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:110:13)
    at Route.dispatch (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:91:3)
    at Layer.handle [as handle_request] (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/layer.js:82:5)
    at /home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/index.js:267:22
    at Function.proto.process_params (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/index.js:321:12)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/index.js:261:10)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:100:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at /home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/lib/server/controller.js:39:7
    at Layer.handle [as handle_request] (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/layer.js:82:5)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:110:13)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at next (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
    at Route.dispatch (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/route.js:91:3)
    at Layer.handle [as handle_request] (/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/node_modules/express/lib/router/layer.js:82:5)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Requested a new session but one was in progress)","origValue":"Requested a new session but one was in progress"},"sessionId":"84d6562d-bc8e-4f8d-8786-42e71a24afaa"}
info: <-- POST /wd/hub/session 500 8.843 ms - 250 
undefined

When you have displayed contexts, you are getting WEBVIEW_My_App. Try using this

If you mean to set it manually like this:

driver.context("WEBVIEW_My_App");

It does not help.

Also is it required to install chromium on my RH?

A full log or error:

info: Client User-Agent string: Apache-HttpClient/4.4.1 (Java/1.7.0)
info: [debug] Didn't get app but did get Android package, will attempt to launch it on the device
info: [debug] Creating new appium session 0f7675d9-bf5c-40a2-bfc7-997cb4533996
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.7.0
info: [debug] Checking whether adb is present
info: [debug] Using adb from /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb
warn: No app capability, can't parse package/activity
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it's already on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb devices
info: [debug] 1 device(s) connected
info: Found device emulator-5554
info: [debug] Setting device id to emulator-5554
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 wait-for-device
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 21
info: Device API level is: 21
info: [debug] Extracting strings for language: default
info: [debug] Apk doesn't exist locally
info: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "rm -rf /data/local/tmp/strings.json"
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Skipping install since we launched with a package instead of an app path
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device...
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 push "/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/build/android_bootstrap/AppiumBootstrap.jar" /data/local/tmp/
info: [debug] Pushing settings apk to device...
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 install "/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/build/settings_apk/settings_apk-debug.apk"
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 install "/home/kacinauskasl/.nvm/versions/node/v0.12.5/lib/node_modules/appium/build/unlock_apk/unlock_apk-debug.apk"
info: Starting App
info: [debug] Attempting to kill all 'uiautomator' processes
info: [debug] Getting all processes with 'uiautomator'
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "ps 'uiautomator'"
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg My_App-e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json...
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] Waking up device if it's not alive
info: [debug] Pushing command to appium work queue: ["wake",{}]
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"wake","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: wake
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "dumpsys window"
info: [debug] Screen already unlocked, continuing.
info: [debug] Pushing command to appium work queue: ["getDataDir",{}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"\/data"}
info: [debug] dataDir set to: /data
info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] Getting device API level
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "getprop ro.build.version.sdk"
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":false}
info: [debug] Device is at API Level 21
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n My_App"
info: [debug] We tried to start an activity that doesn't exist, retrying with . prepended to activity
info: [debug] Getting device API level
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 21
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n My_App"
info: [debug] Waiting for pkg "My_App" and activity "My_App" to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "dumpsys window windows"
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "getprop ro.build.version.release"
info: [debug] Device is at release version 5.0.2
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to 60 secs
info: [debug] Appium session started with sessionId 0f7675d9-bf5c-40a2-bfc7-997cb4533996
info: <-- POST /wd/hub/session 303 4677.568 ms - 74 
info: --> GET /wd/hub/session/0f7675d9-bf5c-40a2-bfc7-997cb4533996 {}
info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"5.0.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"automationName":"appium","newCommandTimeout":60,"platformVersion":"4.4.2","deviceName":"Galaxy","platformName":"Android","appActivity":"My_App","appPackage":"My_App"},"automationName":"appium","newCommandTimeout":60,"deviceName":"emulator-5554","platformName":"Android","appActivity":"My_App","appPackage":"My_App"},"sessionId":"0f7675d9-bf5c-40a2-bfc7-997cb4533996"}
info: <-- GET /wd/hub/session/0f7675d9-bf5c-40a2-bfc7-997cb4533996 200 6.193 ms - 712 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"5.0.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"automationName":"appium","newCommandTimeout":60,"platformVersion":"4.4.2","deviceName":"Galaxy","platformName":"Android","appActivity":"My_App","appPackage":"My_App"},"automationName":"appium","newCommandTimeout":60,"deviceName":"emulator-5554","platformName":"Android","appActivity":"My_App","appPackage":"My_App"},"sessionId":"0f7675d9-bf5c-40a2-bfc7-997cb4533996"}
info: --> GET /wd/hub/session/0f7675d9-bf5c-40a2-bfc7-997cb4533996/contexts {}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "cat /proc/net/unix"
info: [debug] WEBVIEW_2585 mapped to pid 2585
info: [debug] Getting process name for webview
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "ps"
info: [debug] Parsed pid: 2585 pkg: My_App
info: [debug] from: u0_a58,2585,937,806904,127700,ffffffff,b76a18b5,S,My_App
info: [debug] returning process name: My_App
info: [debug] Available contexts: 
info: [debug] ["WEBVIEW_My_App"]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_My_App
info: [debug] Responding to client with success: {"status":0,"value":["NATIVE_APP","WEBVIEW_My_App"],"sessionId":"0f7675d9-bf5c-40a2-bfc7-997cb4533996"}
info: <-- GET /wd/hub/session/0f7675d9-bf5c-40a2-bfc7-997cb4533996/contexts 200 108.904 ms - 122 {"status":0,"value":["NATIVE_APP","WEBVIEW_My_App"],"sessionId":"0f7675d9-bf5c-40a2-bfc7-997cb4533996"}
info: --> POST /wd/hub/session/0f7675d9-bf5c-40a2-bfc7-997cb4533996/context {"name":"WEBVIEW_My_App"}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "cat /proc/net/unix"
info: [debug] WEBVIEW_2585 mapped to pid 2585
info: [debug] Getting process name for webview
info: [debug] executing cmd: /home/kacinauskasl/SDK/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "ps"
info: [debug] Parsed pid: 2585 pkg: My_App
info: [debug] from: u0_a58,2585,937,806904,127736,ffffffff,b76a18b5,S,My_App
info: [debug] returning process name:My_App
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_My_App
info: [debug] ["WEBVIEW_My_App"]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_My_App
info: [debug] Connecting to chrome-backed webview
info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command. (Original error: Cannot read property 'stop' of null)","origValue":"Cannot read property 'stop' of null"},"sessionId":"0f7675d9-bf5c-40a2-bfc7-997cb4533996"}
info: <-- POST /wd/hub/session/0f7675d9-bf5c-40a2-bfc7-997cb4533996/context 500 191.945 ms - 258 
info: [debug] Didn't get a new command in 60 secs, shutting down..

.

The issue could be with GoogleChrome Driver. Are you using the Appium GUI ? If so what version are you using ? You should update to 1.4.0.0. This version fixed my Chromedriver / Android hybrid issue. If the issue still persists, change the automation name on the Appium GUI to selendroid and change the desired capabilities on your code to selendriod.

1 Like

I solved my problem. I renew my libstdc++.so.6 file.

I used
WebView.setWebContentsDebuggingEnabled(true);
But giving the below error stack:

java.lang.RuntimeException: Stub!
at android.webkit.WebView.setWebContentsDebuggingEnabled(WebView.java:136)
at AndroidEngine.startAppiumDriver(AndroidEngine.java:127)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Any idea, why this is raised?

Hello, I’m having the same error.
Can you help me ?

How did you renew your libstdc++.so.6 file ?
I’m using windows.

Sorry for my late reply.
I am using linux, so I did some GCC compiler.
You should update your system if you are using windows I guess.

Even I have the same Issue? @anapadinha Do you know the libstdc__.so.6 equivalent for windows ? Please let me know…

@LaurynasKac please let me know how this can be solved in Windows? Is there a way to solve this in windows? or why is the problem caused ? I have the error code as same as yours…Here I am using Appium UI with 2 instances of Appium (with different ports) in the same machine. The console Log on eclipse says sessionnotfoundexception:No such session

I have written code in the following way which solved my problem.

DesiredCapabilities cap= new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM_NAME,MobilePlatform.ANDROID);
cap.setCapability(“noReset”, “true”);
cap.setCapability(“browserName”, “Android”);
cap.setCapability(MobileCapabilityType.DEVICE_NAME, “Android Emulator”);
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, “4.4”);
cap.setCapability(MobileCapabilityType.APP_PACKAGE, “gsm.eyc.com”);
cap.setCapability(MobileCapabilityType.APP_ACTIVITY, “gsm.eyc.com.GSMActivity”);

	driver =  new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
	driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

WebDriverWait wait=new WebDriverWait(driver, 10);
Set contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextName);
if (contextName.contains(“WEBVIEW”)){
driver.context(contextName);
}
}

Note: Use Android driver to avoid problems