Testing Hybrid App : "Status 13 : Did not successfully proxy server command"

Hi,

I have an app builded with Cordova latest version (4.3.0) and I get an error on appium server :

Error Response status : 13, UnknownError - An unknown server-side error occurred while processing the command. Selenium error:An unknown server-side error occurred while processing the command.

I’m using Selendroid driver and I’m switching to the webview at the begining of my test. I’m using WD to write my test in Javascript and I have no error when I switch, just when I try to find element.

In the logcat I found this :

E/SELENDROID( 3749): java.lang.ClassCastException: io.selendroid.server.model.SelendroidWebDriver$SelendroidWebChromeClient cannot be cast to org.apache.cordova.CordovaChromeClient

This bug was solved in Selendroid 0.15.0. Does Appium use this version ? (See the folowing links : “Can not run Hybrid app with Cordova version”, “Cannot run Cordova hybrid app”, “Fixing support for cordova 3.7.0 apps.”)

Here the file.

Test.js :

var wd = require('wd');
require('colors');
describe('android test', function(){
	this.timeout(300000);
	var driver;
	var allPassed = true;

	before(function() {
		var serverConfig = {
							  host: '127.0.0.1',
							  port: 4723
							};
		driver = wd.promiseChainRemote(serverConfig);
		driver.on('status', function (info) {
	   		 console.log(info.cyan);
		});
		driver.on('command', function (meth, path, data) {
		    console.log(' > ' + meth.yellow, path.grey, data || '');
		});
		driver.on('http', function (meth, path, data) {
		    console.log(' > ' + meth.magenta, path, (data || '').grey);
		});

		var desired = {
			browserName: '',
			'appium-version': '1.3.7',
			platformName: 'Android',
			automationName: 'Selendroid',
			udid: '192.168.56.101:5555',
			platformVersion : '4.1.1',
			deviceName: 'android_test',
			app: 'absolutePath/CordovaApp-debug.apk' //I hide the path of the app
		};

		return driver.init(desired).setImplicitWaitTimeout(5000).currentContext().contexts().then(function (contexts){
				console.log(contexts);
				return driver.context(contexts[1]);
			});
	});

	after(function () {

		return driver.quit();
	});

	afterEach(function () {
		allPassed = allPassed && this.currentTest.state == 'passed';
	});
	it("Test Hybrid", function() {

		return driver
			
			.hasElementById('nameDevice')
			;
	});

	

});

Log Server :

2015-04-21 13:49:49:819 - info: Welcome to Appium v1.3.7 (REV 72fbfaa116d3d9f6a862600ee99cf02f6d0e2182)
2015-04-21 13:49:49:822 - info: Appium REST http interface listener started on 127.0.0.1:4723
2015-04-21 13:49:49:825 - info: [debug] Non-default server args: {"address":"127.0.0.1","fullReset":true,"log":"C:\\Users\\...\\Documents\\log_appium","selendroidPort":4444}
2015-04-21 13:49:49:826 - info: Console LogLevel: debug
2015-04-21 13:49:49:826 - info: File LogLevel: debug
2015-04-21 13:50:00:787 - info: --> POST /wd/hub/session {"desiredCapabilities":{"browserName":"","appium-version":"1.3.7","platformName":"Android","automationName":"Selendroid","udid":"192.168.56.101:5555","platformVersion":"4.1.1","deviceName":"android_test","app":"C:/Users/.../Documents/NodeAppium/phonegap/CordovaApp-debug.apk"}}
2015-04-21 13:50:00:789 - info: Client User-Agent string: undefined
2015-04-21 13:50:00:791 - info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : appium-version
2015-04-21 13:50:00:792 - info: [debug] No appActivity desired capability or server param. Parsing from apk.
2015-04-21 13:50:00:793 - info: [debug] No appPackage desired capability or server param. Parsing from apk.
2015-04-21 13:50:00:793 - info: [debug] Using local app from desired caps: C:\Users\...\Documents\NodeAppium\phonegap\CordovaApp-debug.apk
2015-04-21 13:50:00:795 - info: [debug] Creating new appium session 4f3d7a6d-1645-4a93-847d-960232358ba8
2015-04-21 13:50:00:796 - info: [debug] Starting selendroid server
2015-04-21 13:50:00:797 - info: [debug] Getting Java version
2015-04-21 13:50:00:912 - info: Java version is: 1.8.0_45
2015-04-21 13:50:00:914 - info: [debug] Checking whether adb is present
2015-04-21 13:50:00:915 - info: [debug] Using adb from C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe
2015-04-21 13:50:00:915 - info: [debug] Checking whether selendroid is built yet
2015-04-21 13:50:00:916 - info: [debug] Selendroid server exists!
2015-04-21 13:50:00:916 - info: [debug] Using fast reset? false
2015-04-21 13:50:00:916 - info: [debug] Preparing device for session
2015-04-21 13:50:00:917 - info: [debug] Checking whether app is actually present
2015-04-21 13:50:00:918 - info: Retrieving device
2015-04-21 13:50:00:919 - info: [debug] Trying to find a connected android device
2015-04-21 13:50:00:920 - info: [debug] Getting connected devices...
2015-04-21 13:50:00:923 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe devices
2015-04-21 13:50:00:985 - info: [debug] 1 device(s) connected
2015-04-21 13:50:00:986 - info: Found device 192.168.56.101:5555
2015-04-21 13:50:00:986 - info: [debug] Setting device id to 192.168.56.101:5555
2015-04-21 13:50:00:986 - info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
2015-04-21 13:50:00:988 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 wait-for-device
2015-04-21 13:50:01:049 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "echo 'ready'"
2015-04-21 13:50:01:114 - info: [debug] Starting logcat capture
2015-04-21 13:50:01:165 - info: [debug] Checking whether aapt is present
2015-04-21 13:50:01:167 - info: [debug] Using aapt from C:\Users\...\AppData\Local\Android\android-sdk\build-tools\22.0.1\aapt.exe
2015-04-21 13:50:01:168 - info: [debug] Checking if has internet permission from manifest.
2015-04-21 13:50:01:172 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\build-tools\22.0.1\aapt.exe dump badging C:\Users\...\Documents\NodeAppium\phonegap\CordovaApp-debug.apk
2015-04-21 13:50:01:264 - info: [debug] Parsing package and activity from app manifest
2015-04-21 13:50:01:266 - info: [debug] Checking whether aapt is present
2015-04-21 13:50:01:267 - info: [debug] Using aapt from C:\Users\...\AppData\Local\Android\android-sdk\build-tools\22.0.1\aapt.exe
2015-04-21 13:50:01:268 - info: [debug] Extracting package and launch activity from manifest.
2015-04-21 13:50:01:269 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\build-tools\22.0.1\aapt.exe dump badging C:\Users\...\Documents\NodeAppium\phonegap\CordovaApp-debug.apk
2015-04-21 13:50:01:355 - info: [debug] badging package: com.phonegap.helloworld
2015-04-21 13:50:01:356 - info: [debug] badging act: com.phonegap.helloworld.CordovaApp
2015-04-21 13:50:01:357 - info: [debug] Parsed package and activity are: com.phonegap.helloworld/com.phonegap.helloworld.CordovaApp
2015-04-21 13:50:01:359 - info: [debug] Rebuilt selendroid server already exists, no need to rebuild it with a new manifest
2015-04-21 13:50:01:360 - info: [debug] Checking signed status of C:\Users\...\DOCUME~1\Temp\selendroid.com.phonegap.helloworld.apk
2015-04-21 13:50:01:361 - info: [debug] Checking app cert for C:\Users\...\DOCUME~1\Temp\selendroid.com.phonegap.helloworld.apk.
2015-04-21 13:50:01:362 - info: [debug] executing cmd: java -jar C:\Users\...\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\jars\verify.jar C:\Users\...\DOCUME~1\Temp\selendroid.com.phonegap.helloworld.apk
2015-04-21 13:50:01:367 - info: [debug] Checking signed status of C:\Users\...\Documents\NodeAppium\phonegap\CordovaApp-debug.apk
2015-04-21 13:50:01:369 - info: [debug] Checking app cert for C:\Users\...\Documents\NodeAppium\phonegap\CordovaApp-debug.apk.
2015-04-21 13:50:01:371 - info: [debug] executing cmd: java -jar C:\Users\..\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\jars\verify.jar C:\Users\...\Documents\NodeAppium\phonegap\CordovaApp-debug.apk
2015-04-21 13:50:01:701 - info: [debug] App already signed.
2015-04-21 13:50:01:702 - info: [debug] Zip-aligning C:\Users\...\Documents\NodeAppium\phonegap\CordovaApp-debug.apk
2015-04-21 13:50:01:704 - info: [debug] Checking whether zipalign is present
2015-04-21 13:50:01:705 - info: [debug] Using zipalign from C:\Users\...\AppData\Local\Android\android-sdk\build-tools\22.0.1\zipalign.exe
2015-04-21 13:50:01:710 - info: [debug] Zip-aligning apk.
2015-04-21 13:50:01:710 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\build-tools\22.0.1\zipalign.exe -f 4 C:\Users\...\Documents\NodeAppium\phonegap\CordovaApp-debug.apk C:\Users\...\DOCUME~1\Temp\115321-7380-17hs9ai\appium.tmp
2015-04-21 13:50:01:735 - info: [debug] App already signed.
2015-04-21 13:50:01:735 - info: [debug] Zip-aligning C:\Users\...\DOCUME~1\Temp\selendroid.com.phonegap.helloworld.apk
2015-04-21 13:50:01:736 - info: [debug] Checking whether zipalign is present
2015-04-21 13:50:01:738 - info: [debug] Using zipalign from C:\Users\...\AppData\Local\Android\android-sdk\build-tools\22.0.1\zipalign.exe
2015-04-21 13:50:01:740 - info: [debug] Zip-aligning apk.
2015-04-21 13:50:01:741 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\build-tools\22.0.1\zipalign.exe -f 4 C:\Users\...\DOCUME~1\Temp\selendroid.com.phonegap.helloworld.apk C:\Users\...\DOCUME~1\Temp\115321-7380-63avui\appium.tmp
2015-04-21 13:50:01:827 - info: [debug] Rebuilt selendroid apk exists, doing nothing
2015-04-21 13:50:01:829 - info: [debug] Getting install status for com.phonegap.helloworld.selendroid
2015-04-21 13:50:01:832 - info: [debug] Getting device API level
2015-04-21 13:50:01:833 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "getprop ro.build.version.sdk"
2015-04-21 13:50:01:843 - info: [debug] MD5 for selendroid server is b2a85d6314cef2ecfd77a181dee6fa6c
2015-04-21 13:50:01:904 - info: [debug] Device is at API Level 19
2015-04-21 13:50:01:905 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "pm list packages -3 com.phonegap.helloworld.selendroid"
2015-04-21 13:50:02:309 - info: [debug] App is installed
2015-04-21 13:50:02:310 - info: [debug] Rebuilt selendroid is already installed
2015-04-21 13:50:02:311 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "getprop persist.sys.language"
2015-04-21 13:50:02:381 - info: [debug] Current device persist.sys.language: en
2015-04-21 13:50:02:381 - info: [debug] java -jar "C:\Users\...\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "C:\Users\...\Documents\NodeAppium\phonegap\CordovaApp-debug.apk" "C:\Users\...\DOCUME~1\Temp\com.phonegap.helloworld" en
2015-04-21 13:50:02:915 - info: [debug] No strings.xml for language 'en', getting default strings.xml
2015-04-21 13:50:02:915 - info: [debug] java -jar "C:\Users\...\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "C:\Users\...\Documents\NodeAppium\phonegap\CordovaApp-debug.apk" "C:\Users\...\DOCUME~1\Temp\com.phonegap.helloworld"
2015-04-21 13:50:03:448 - info: [debug] Uninstalling com.phonegap.helloworld
2015-04-21 13:50:03:449 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "am force-stop com.phonegap.helloworld"
2015-04-21 13:50:03:822 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 uninstall com.phonegap.helloworld
2015-04-21 13:50:04:383 - info: [debug] App was uninstalled
2015-04-21 13:50:04:408 - info: [debug] Checking app cert for C:\Users\...\Documents\NodeAppium\phonegap\CordovaApp-debug.apk.
2015-04-21 13:50:04:431 - info: [debug] executing cmd: java -jar C:\Users\...\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\jars\verify.jar C:\Users\...\Documents\NodeAppium\phonegap\CordovaApp-debug.apk
2015-04-21 13:50:04:723 - info: [debug] App already signed.
2015-04-21 13:50:04:724 - info: [debug] Zip-aligning C:\Users\...\Documents\NodeAppium\phonegap\CordovaApp-debug.apk
2015-04-21 13:50:04:724 - info: [debug] Checking whether zipalign is present
2015-04-21 13:50:04:725 - info: [debug] Using zipalign from C:\Users\...\AppData\Local\Android\android-sdk\build-tools\22.0.1\zipalign.exe
2015-04-21 13:50:04:726 - info: [debug] Zip-aligning apk.
2015-04-21 13:50:04:727 - info: [debug] executing cmd: C:\Users...\AppData\Local\Android\android-sdk\build-tools\22.0.1\zipalign.exe -f 4 C:\Users\...\Documents\NodeAppium\phonegap\CordovaApp-debug.apk C:\Users\...\DOCUME~1\Temp\115321-7380-bf5s8s\appium.tmp
2015-04-21 13:50:04:801 - info: [debug] MD5 for app is 0639a72b3169d96314bdafbf2d6b850b
2015-04-21 13:50:04:801 - info: [debug] executing cmd: C:\Users...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "ls /data/local/tmp/0639a72b3169d96314bdafbf2d6b850b.apk"
2015-04-21 13:50:04:865 - info: [debug] Getting install status for com.phonegap.helloworld
2015-04-21 13:50:04:865 - info: [debug] Getting device API level
2015-04-21 13:50:04:866 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "getprop ro.build.version.sdk"
2015-04-21 13:50:04:936 - info: [debug] Device is at API Level 19
2015-04-21 13:50:04:937 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "pm list packages -3 com.phonegap.helloworld"
2015-04-21 13:50:05:329 - info: [debug] App is not installed
2015-04-21 13:50:05:330 - info: Installing App
2015-04-21 13:50:05:330 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "mkdir -p /data/local/tmp/"
2015-04-21 13:50:05:399 - info: [debug] Removing any old apks
2015-04-21 13:50:05:400 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "ls /data/local/tmp/*.apk"
2015-04-21 13:50:05:472 - info: [debug] Found an apk we want to keep at /data/local/tmp/0639a72b3169d96314bdafbf2d6b850b.apk
2015-04-21 13:50:05:472 - info: [debug] Couldn't find any apks to remove
2015-04-21 13:50:05:473 - info: [debug] Uninstalling com.phonegap.helloworld
2015-04-21 13:50:05:473 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "am force-stop com.phonegap.helloworld"
2015-04-21 13:50:05:856 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 uninstall com.phonegap.helloworld
2015-04-21 13:50:06:268 - info: [debug] App was not uninstalled, maybe it wasn't on device?
2015-04-21 13:50:06:269 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "pm install -r /data/local/tmp/0639a72b3169d96314bdafbf2d6b850b.apk"
2015-04-21 13:50:06:865 - info: [debug] Forwarding system:4444 to device:8080
2015-04-21 13:50:06:867 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 forward tcp:4444 tcp:8080
2015-04-21 13:50:06:940 - info: [debug] Pushing settings apk to device...
2015-04-21 13:50:06:941 - info: [debug] executing cmd: C:\Users...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 install "C:\Users\...\AppData\Roaming\npm\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
2015-04-21 13:50:07:441 - info: [debug] Pushing unlock helper app to device...
2015-04-21 13:50:07:442 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 install "C:\Users\...\AppData\Roaming\npm\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
2015-04-21 13:50:07:935 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "dumpsys window"
2015-04-21 13:50:08:024 - info: Unlocking screen
2015-04-21 13:50:08:025 - info: [debug] Screen is locked, trying to unlock
2015-04-21 13:50:08:026 - info: [debug] Getting device API level
2015-04-21 13:50:08:027 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "getprop ro.build.version.sdk"
2015-04-21 13:50:08:103 - info: [debug] Device is at API Level 19
2015-04-21 13:50:08:104 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock"
2015-04-21 13:50:08:901 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "dumpsys window"
2015-04-21 13:50:09:079 - info: [debug] Screen is unlocked, continuing
2015-04-21 13:50:09:088 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "am instrument -e main_activity 'com.phonegap.helloworld.CordovaApp' com.phonegap.helloworld.selendroid/io.selendroid.server.ServerInstrumentation"
2015-04-21 13:50:09:666 - info: [debug] Making http request with opts: {"url":"http://localhost:4444/wd/hub/status","method":"GET"}
2015-04-21 13:50:10:493 - info: [debug] Making http request with opts: {"url":"http://localhost:4444/wd/hub/status","method":"GET"}
2015-04-21 13:50:10:569 - info: [debug] Selendroid server is alive!
2015-04-21 13:50:10:570 - info: [debug] Listening for Selendroid logs
2015-04-21 13:50:10:571 - info: [debug] Creating Selendroid session
2015-04-21 13:50:10:581 - info: [debug] Making http request with opts: {"url":"http://localhost:4444/wd/hub/session","method":"POST","json":{"desiredCapabilities":{"warnings":{},"desired":{"browserName":"","appium-version":"1.3.7","platformName":"Android","automationName":"Selendroid","udid":"192.168.56.101:5555","platformVersion":"4.1.1","deviceName":"android_test","app":"C:/Users/.../Documents/NodeAppium/phonegap/CordovaApp-debug.apk"},"browserName":"","appium-version":"1.3.7","platformName":"Android","automationName":"Selendroid","udid":"192.168.56.101:5555","platformVersion":"4.1.1","deviceName":"android_test","app":"C:/Users/.../Documents/NodeAppium/phonegap/CordovaApp-debug.apk"}}}
2015-04-21 13:50:10:631 - info: [debug] Successfully started selendroid session
2015-04-21 13:50:10:635 - info: [debug] Waiting for pkg "com.phonegap.helloworld" and activity "com.phonegap.helloworld.CordovaApp" to be focused
2015-04-21 13:50:10:636 - info: [debug] Getting focused package and activity
2015-04-21 13:50:10:640 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "dumpsys window windows"
2015-04-21 13:50:10:757 - info: [debug] Overriding session id with "073b49b8-d6c0-b49e-538e-f7944898b38b"
2015-04-21 13:50:10:758 - info: [debug] Device launched! Ready for commands
2015-04-21 13:50:10:759 - info: [debug] Setting command timeout to the default of 60 secs
2015-04-21 13:50:10:760 - info: [debug] Appium session started with sessionId 073b49b8-d6c0-b49e-538e-f7944898b38b
2015-04-21 13:50:10:766 - info: <-- POST /wd/hub/session 303 9990.853 ms - 74 
2015-04-21 13:50:10:791 - info: --> POST /wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/timeouts/implicit_wait {"ms":5000}
2015-04-21 13:50:10:793 - info: [debug] Proxying command to localhost:4444
2015-04-21 13:50:10:793 - info: [debug] Making http request with opts: {"url":"http://localhost:4444/wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/timeouts/implicit_wait","method":"POST","json":{"ms":5000}}
2015-04-21 13:50:10:807 - info: [debug] Proxied response received with status 200: {"value":"","status":0,"sessionId":"073b49b8-d6c0-b49e-538e-f7944898b38b"}
2015-04-21 13:50:10:817 - info: <-- POST /wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/timeouts/implicit_wait 200 20.787 ms - 74 
2015-04-21 13:50:10:829 - info: --> GET /wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/context {}
2015-04-21 13:50:10:833 - info: [debug] Responding to client with success: {"status":0,"value":"NATIVE_APP","sessionId":"073b49b8-d6c0-b49e-538e-f7944898b38b"}
2015-04-21 13:50:10:841 - info: <-- GET /wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/context 200 8.602 ms - 84 {"status":0,"value":"NATIVE_APP","sessionId":"073b49b8-d6c0-b49e-538e-f7944898b38b"}
2015-04-21 13:50:10:852 - info: --> GET /wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/contexts {}
2015-04-21 13:50:10:855 - info: [debug] Getting a list of available webviews
2015-04-21 13:50:10:857 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "cat /proc/net/unix"
2015-04-21 13:50:10:945 - info: [debug] WEBVIEW_3749 mapped to pid 3749
2015-04-21 13:50:10:946 - info: [debug] Getting process name for webview
2015-04-21 13:50:10:947 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "ps"
2015-04-21 13:50:11:035 - info: [debug] Parsed pid: 3749 pkg: com.phonegap.helloworld
2015-04-21 13:50:11:035 - info: [debug] from: u0_a86,3749,147,659288,61548,ffffffff,b76dba23,S,com.phonegap.helloworld
2015-04-21 13:50:11:035 - info: [debug] returning process name: com.phonegap.helloworld
2015-04-21 13:50:11:036 - info: [debug] Available contexts: undefined
2015-04-21 13:50:11:036 - info: [debug] ["WEBVIEW_com.phonegap.helloworld"]
2015-04-21 13:50:11:037 - info: [debug] Making http request with opts: {"url":"http://localhost:4444/wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/window_handles","method":"GET"}
2015-04-21 13:50:11:050 - info: [debug] Available contexts: ["NATIVE_APP","WEBVIEW_0"]
2015-04-21 13:50:11:051 - info: [debug] Responding to client with success: {"status":0,"value":["NATIVE_APP","WEBVIEW_0"],"sessionId":"073b49b8-d6c0-b49e-538e-f7944898b38b"}
2015-04-21 13:50:11:058 - info: <-- GET /wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/contexts 200 202.079 ms - 98 {"status":0,"value":["NATIVE_APP","WEBVIEW_0"],"sessionId":"073b49b8-d6c0-b49e-538e-f7944898b38b"}
2015-04-21 13:50:11:070 - info: --> POST /wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/context {"name":"WEBVIEW_0"}
2015-04-21 13:50:11:072 - info: [debug] Getting a list of available webviews
2015-04-21 13:50:11:073 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "cat /proc/net/unix"
2015-04-21 13:50:11:173 - info: [debug] WEBVIEW_3749 mapped to pid 3749
2015-04-21 13:50:11:174 - info: [debug] Getting process name for webview
2015-04-21 13:50:11:176 - info: [debug] executing cmd: C:\Users\...\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "ps"
2015-04-21 13:50:11:278 - info: [debug] Parsed pid: 3749 pkg: com.phonegap.helloworld
2015-04-21 13:50:11:279 - info: [debug] from: u0_a86,3749,147,674924,67336,ffffffff,b76dba23,S,com.phonegap.helloworld
2015-04-21 13:50:11:279 - info: [debug] returning process name: com.phonegap.helloworld
2015-04-21 13:50:11:279 - info: [debug] Available contexts: NATIVE_APP,WEBVIEW_0
2015-04-21 13:50:11:280 - info: [debug] ["WEBVIEW_com.phonegap.helloworld"]
2015-04-21 13:50:11:281 - info: [debug] Making http request with opts: {"url":"http://localhost:4444/wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/window_handles","method":"GET"}
2015-04-21 13:50:11:302 - info: [debug] Available contexts: ["NATIVE_APP","WEBVIEW_0"]
2015-04-21 13:50:11:304 - info: [debug] Making http request with opts: {"url":"http://localhost:4444/wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/context","method":"POST","json":{"name":"WEBVIEW_0"}}
2015-04-21 13:50:11:385 - info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"073b49b8-d6c0-b49e-538e-f7944898b38b"}
2015-04-21 13:50:11:388 - info: <-- POST /wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/context 200 318.999 ms - 76 {"status":0,"value":null,"sessionId":"073b49b8-d6c0-b49e-538e-f7944898b38b"}
2015-04-21 13:50:11:417 - info: --> POST /wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/elements {"using":"link text","value":"Feed me more !"}
2015-04-21 13:50:11:418 - info: [debug] Proxying command to localhost:4444
2015-04-21 13:50:11:420 - info: [debug] Making http request with opts: {"url":"http://localhost:4444/wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/elements","method":"POST","json":{"using":"link text","value":"Feed me more !"}}
2015-04-21 13:50:12:289 - info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"Did not successfully proxy server command"},"sessionId":"073b49b8-d6c0-b49e-538e-f7944898b38b"}
2015-04-21 13:50:12:300 - info: <-- POST /wd/hub/session/073b49b8-d6c0-b49e-538e-f7944898b38b/elements 500 877.528 ms - 210 

I have tried to run on Android 4.4 and 4.1 but not on real device.

Thanks for the help.

Found the solution :

First follow this :

  1. Clone the Cordova from github: https://github.com/apache/cordova-android
  2. Build the library with Ant
  3. Add jar to maven local repo, see this for details: http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
  4. Modify the selendroid-standalone pom.xml to contain the cordova jar as runtime dependency.

5)After you must edit the SelendroidWebDriver.java file.

edit this lines

 if (view.getClass().getSimpleName().equalsIgnoreCase("CordovaWebView")) {
            CordovaWebView webview=(CordovaWebView)view;
            CordovaInterface ci=null;
            chromeClient = new ExtendedCordovaChromeClient(null,webview);
} else {
            chromeClient = new SelendroidWebChromeClient();
}

To :

 if (view.getClass().getSimpleName().equalsIgnoreCase("CordovaWebView")) {
            CordovaWebView webview=(CordovaWebView)view;
            CordovaInterface ci=null;
            chromeClient = new ExtendedCordovaChromeClient(null,webview);
} else if (view.getClass().getSimpleName().equalsIgnoreCase("SystemWebView")) {
            SystemWebView webview=(SystemWebView)view;
            SystemWebViewEngine webEngine= new SystemWebViewEngine(webview);
            chromeClient = new ExtendedSystemWebChromeClient(webEngine);
} else {
            chromeClient = new SelendroidWebChromeClient();
}

And add this classe to the file (its just a copy of ExtendedCordovaChromeClient):

public class ExtendedSystemWebChromeClient extends SystemWebChromeClient {


    public  ExtendedSystemWebChromeClient(SystemWebViewEngine parentEngine) {
      super(parentEngine);
    }

    /**
     * Unconventional way of adding a Javascript interface but the main reason why I took this way
     * is that it is working stable compared to the webview.addJavascriptInterface way.
     **/
   @Override
    public boolean onJsAlert(WebView view, String url, String message, JsResult jsResult) {
      if (message != null && message.startsWith("selendroid<")) {
        jsResult.confirm();

        synchronized (syncObject) {
          String res = message.replaceFirst("selendroid<", "");
          int i = res.indexOf(">:");
          String enc = res.substring(0, i);
          res = res.substring(i + 2);
          
          /* Workaround for Japanese character encodings: Replace U+00A5 with backslash so that we
           * can properly parse JSON strings contains backslash escapes, since WebKit maps 0x5C
           * (used for character escaping in all of the Japanses character encodings) to U+00A5 (YEN
           * SIGN) and breaks escape characters.
           */
          if (("EUC-JP".equals(enc) || "Shift_JIS".equals(enc) || "ISO-2022-JP".equals(enc))
              && res.contains("\u00a5")) {
            SelendroidLogger.info("Perform workaround for japanese character encodings");
            SelendroidLogger.debug("Original String: " + res);
            res = res.replace("\u00a5", "\\");
            SelendroidLogger.debug("Replaced result: " + res);
          }
          result = res;
          syncObject.notify();
        }

        return true;
      } else {
        currentAlertMessage.add(message == null ? "null" : message);
        SelendroidLogger.info("new alert message: " + message);
        return super.onJsAlert(view, url, message, jsResult);
      }
    }
  }
  1. Re-build the source :
.\reset.bat --selendroid
  1. Clear cache file related to Selendroid

Its a temporary solution . But I made a pull request to Selendroid.

Edit : PR merged on master branch.

I am getting similar issue, here is the logcat:

java.lang.ClassCastException: io.selendroid.server.model.AndroidNativeElement$WebViewSourceClient cannot be cast to org.apache.cordova.CordovaChromeClient
at org.apache.cordova.CordovaWebView.setWebChromeClient(CordovaWebView.java:332)
at io.selendroid.server.model.AndroidNativeElement$4.run(AndroidNativeElement.java:383)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

i get below appium selendroid error:

info: [debug] Getting a list of available webviews
info: [debug] executing cmd: /Users/hardik/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “cat /proc/net/unix”
info: [debug] WEBVIEW_7002 mapped to pid 7002
info: [debug] Getting process name for webview
info: [debug] executing cmd: /Users/hardik/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “ps”
info: [debug] Parsed pid: 7002 pkg: com.paynearme.consumer.dev
info: [debug] from: u0_a58,7002,945,966124,232304,ffffffff,b76bb0b5,S,com.paynearme.consumer.dev
info: [debug] returning process name: com.paynearme.consumer.dev
info: [debug] Available contexts: WEBVIEW_0,NATIVE_APP
info: [debug] [“WEBVIEW_com.paynearme.consumer.dev”]
info: [debug] Making http request with opts: {“url”:“http://localhost:8080/wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/window_handles",“method”:"GET”}
info: [debug] Available contexts: [“WEBVIEW_0”,“NATIVE_APP”]
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“76b74361-b307-b7e9-67fa-9da66b281a96”}
info: <-- POST /wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/context 200 92.415 ms - 76 {“status”:0,“value”:null,“sessionId”:“76b74361-b307-b7e9-67fa-9da66b281a96”}
info: --> POST /wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/context {“name”:“NATIVE_APP”}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: /Users/hardik/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “cat /proc/net/unix”
info: [debug] WEBVIEW_7002 mapped to pid 7002
info: [debug] Getting process name for webview
info: [debug] executing cmd: /Users/hardik/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “ps”
info: [debug] Parsed pid: 7002 pkg: com.paynearme.consumer.dev
info: [debug] from: u0_a58,7002,945,966124,232372,ffffffff,b76bb0b5,S,com.paynearme.consumer.dev
info: [debug] returning process name: com.paynearme.consumer.dev
info: [debug] Available contexts: WEBVIEW_0,NATIVE_APP
info: [debug] [“WEBVIEW_com.paynearme.consumer.dev”]
info: [debug] Making http request with opts: {“url”:“http://localhost:8080/wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/window_handles",“method”:"GET”}
info: [debug] Available contexts: [“WEBVIEW_0”,“NATIVE_APP”]
info: [debug] Making http request with opts: {“url”:“http://localhost:8080/wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/context",“method”:“POST”,“json”:{“name”:"NATIVE_APP”}}
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“76b74361-b307-b7e9-67fa-9da66b281a96”}
info: <-- POST /wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/context 200 103.534 ms - 76 {“status”:0,“value”:null,“sessionId”:“76b74361-b307-b7e9-67fa-9da66b281a96”}
info: --> GET /wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/context {}
info: [debug] Responding to client with success: {“status”:0,“value”:“NATIVE_APP”,“sessionId”:“76b74361-b307-b7e9-67fa-9da66b281a96”}
info: <-- GET /wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/context 200 0.624 ms - 84 {“status”:0,“value”:“NATIVE_APP”,“sessionId”:“76b74361-b307-b7e9-67fa-9da66b281a96”}
info: --> POST /wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/context {“name”:“NATIVE_APP”}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: /Users/hardik/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “cat /proc/net/unix”
info: [debug] WEBVIEW_7002 mapped to pid 7002
info: [debug] Getting process name for webview
info: [debug] executing cmd: /Users/hardik/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “ps”
info: [debug] Parsed pid: 7002 pkg: com.paynearme.consumer.dev
info: [debug] from: u0_a58,7002,945,966124,232668,ffffffff,b7658d52,S,com.paynearme.consumer.dev
info: [debug] returning process name: com.paynearme.consumer.dev
info: [debug] Available contexts: WEBVIEW_0,NATIVE_APP
info: [debug] [“WEBVIEW_com.paynearme.consumer.dev”]
info: [debug] Making http request with opts: {“url”:“http://localhost:8080/wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/window_handles",“method”:"GET”}
info: [debug] Available contexts: [“WEBVIEW_0”,“NATIVE_APP”]
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“76b74361-b307-b7e9-67fa-9da66b281a96”}
info: <-- POST /wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/context 200 98.641 ms - 76 {“status”:0,“value”:null,“sessionId”:“76b74361-b307-b7e9-67fa-9da66b281a96”}
info: --> POST /wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/element {“using”:“xpath”,“value”:"//[@name=“Unknown zip code”]"}
info: [debug] Proxying command to localhost:8080
info: [debug] Making http request with opts: {“url”:"http://localhost:8080/wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/element",“method”:“POST”,“json”:{“using”:“xpath”,“value”:"//
[@name=“Unknown zip code”]"}}
info: [debug] [SELENDROID] -1
info: [debug] Responding to client with error: {“status”:13,“value”:{“message”:“An unknown server-side error occurred while processing the command.”,“origValue”:“Did not successfully proxy server command”},“sessionId”:“76b74361-b307-b7e9-67fa-9da66b281a96”}
info: <-- POST /wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/element 500 83.468 ms - 210
info: --> POST /wd/hub/session/76b74361-b307-b7e9-67fa-9da66b281a96/element {“using”:“xpath”,“value”:"//*[@name=“Unknown zip code”]"}

Steps:

  • set webview context and perform actions
  • switch to native app view and try to find element. this is where it fails.

Info:

appium --automation-name Selendroid
info: Welcome to Appium v1.4.16 (REV d11c15a516f16d20c77ccc8e1d501957fb65d9eb)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: [debug] Non-default server args: {“automationName”:“Selendroid”}
info: Console LogLevel: debug

Emulator: Nexus_5_API_21_x86 API Level 21