Appium: Update appium-android-driver to search for correct webview regex

Created on 25 Feb 2015  Â·  148Comments  Â·  Source: appium/appium

i just failed to set up testing for hybrid android apps build with cordova/xwalk.

I started reading the code and figured out that appium ich searching for socket with patten

'''
/@?webview_devtools_remote_(\d+)/
'''
here: https://github.com/appium/appium/blob/efd0bf0e53093cee2fd185742c9a1a1c344bdf87/lib/devices/android/android-hybrid.js#L24

I just checked on my Nexus 5 and the socket is actually named:
@chrome_devtools_remote for chrome
@packagename_devtools_remote for my hybrid app

can somebody confirm that? Any fixes/patches already available?

Android Enhancement

Most helpful comment

Patch for chromedriver repo currently in code review.
https://codereview.chromium.org/2375613002/

Appropriate change in appium-android-driver package also needs to be made for identifying the correct webview.

All 148 comments

@bootstraponline @jlipps ideas?

ok just figured out that i can set androidDeviceSocket to packagename_devtools_remote for my hybrid app in capablities and then its able to find it.

but now the chromdriver session cannot be created:

error: Chromedriver create session did not work. Status was 200 and body was {"sessionId":"1ba7c300de2460eb7387e107b1dbacc0","status":100,"value":{"message":"chrome not reachable\n  (Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Linux 3.13.0-46-generic x86_64)"}}
info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command. (Original error: Did not get session redirect from Chromedriver)","origValue":"Did not get session redirect from Chromedriver"},"sessionId":null}

ok and finally i figured out that the issue is one in chromedriver. its trying to connect to the wrong socket in android:

Sending adb command: host-serial:CB5122TKT3:forward:tcp:12509;localabstract:webview_devtools_remote_1186

unfortunately there is no way to convince chromedriver to connect to another socket.

interesting. @paymand how do you get around this with Opera?

just as an update i modified chromedriver recompiled it and now it works. Will talk soon to the chromiumdriver developers how to resolve that properly

@paymand i was not able to get it running with the operaChromiumDriver would love to have a look into the source which is not public right?

The provided binary and examples found at https://github.com/operasoftware/operachromiumdriver are a bit outdated. I'll see if I can get someone to update them.

@paymand i just need to know if they changed the chromedriver to be actually able to find the right unix socket on the device? the current logic seems to be not able to connect to chromeview sockets. It that is the case i can open a ticket in chromedriver

@aluedeke: For Opera mobile (final/beta) we use our modified version of the chromedriver (aka operadriver) and the value I use for androidDeviceSocket cap is app_package + ".devtools".

@aluedeke: FYI, I've updated the docs/examples/executables for OperaDriver:
https://github.com/operasoftware/operachromiumdriver/releases

@aluedeke: I'm performing this issue now. What is your resolution for these days? Are you still using your patched version of chromedriver?

@mpetrak i did only a poc for a customer and didn't had time to investigate this further. i would bet the the issue is still there. Chromium code is still not updated.

Here is my patch:

diff --git a/chrome/test/chromedriver/chrome/device_manager.cc b/chrome/test/chromedriver/chrome/device_manager.cc
index 8e77f0c..00e60d8 100644
--- a/chrome/test/chromedriver/chrome/device_manager.cc
+++ b/chrome/test/chromedriver/chrome/device_manager.cc
@@ -124,18 +124,7 @@ Status Device::ForwardDevtoolsPort(const std::string& package,
                                    int port,
                                    std::string* device_socket) {
   if (device_socket->empty()) {
-    // Assume this is a WebView app.
-    int pid;
-    Status status = adb_->GetPidByName(serial_,
-                                       process.empty() ? package : process,
-                                       &pid);
-    if (status.IsError()) {
-      if (process.empty())
-        status.AddDetails(
-            "process name must be specified if not equal to package name");
-      return status;
-    }
-    *device_socket = base::StringPrintf("webview_devtools_remote_%d", pid);
+    *device_socket = package + "_devtools_remote";
   }

   return adb_->ForwardPort(serial_, port, *device_socket);
@@ -219,4 +208,3 @@ bool DeviceManager::IsDeviceLocked(const std::string& device_serial) {
   return std::find(active_devices_.begin(), active_devices_.end(),
                    device_serial) != active_devices_.end();
 }
-

@aluedeke Thank you for informations

Ok so this is a bug with the workaround. Putting it in new feature, we might have a go at it once most of the more urgent issues are sorted.

here's an open issue for this: crosswalk-project/crosswalk-web-driver#17

I'm using the Cordova Crosswalk plugin and also hitting this. Has there been any resolution on the Chromedriver side?

For what it's worth, here's a fuller Chromedriver patch that exposes androidDeviceSocket as a desired capability under chromeOptions.

This patch works w/ the current version of Appium. Swap in the patched Chromedriver and pass your androidDeviceSocket to Appium in your desiredCapabilities like so

{
  "platformName":"Android",
  "deviceName":"my device",
  "androidDeviceSocket":"my.package_devtools_remote",
  "chromeOptions": {
    "androidDeviceSocket":"my.package_devtools_remote
  }
}

The patch:

diff --git a/chrome/test/chromedriver/capabilities.cc b/chrome/test/chromedriver/capabilities.cc
index 5846479..67de230 100644
--- a/chrome/test/chromedriver/capabilities.cc
+++ b/chrome/test/chromedriver/capabilities.cc
@@ -424,6 +424,8 @@ Status ParseChromeOptions(
         base::Bind(&ParseString, &capabilities->android_package);
     parser_map["androidProcess"] =
         base::Bind(&ParseString, &capabilities->android_process);
+    parser_map["androidDeviceSocket"] =
+        base::Bind(&ParseString, &capabilities->android_device_socket);
     parser_map["androidUseRunningApp"] =
         base::Bind(&ParseBoolean, &capabilities->android_use_running_app);
     parser_map["args"] = base::Bind(&ParseSwitches);
diff --git a/chrome/test/chromedriver/capabilities.h b/chrome/test/chromedriver/capabilities.h
index 2f78fec..85ebc62 100644
--- a/chrome/test/chromedriver/capabilities.h
+++ b/chrome/test/chromedriver/capabilities.h
@@ -105,6 +105,8 @@ struct Capabilities {

   std::string android_process;

+  std::string android_device_socket;
+
   bool android_use_running_app;

   base::FilePath binary;
diff --git a/chrome/test/chromedriver/chrome/device_manager.cc b/chrome/test/chromedriver/chrome/device_manager.cc
index c8c9736..5c92957 100644
--- a/chrome/test/chromedriver/chrome/device_manager.cc
+++ b/chrome/test/chromedriver/chrome/device_manager.cc
@@ -34,6 +34,7 @@ Device::~Device() {
 Status Device::SetUp(const std::string& package,
                      const std::string& activity,
                      const std::string& process,
+                     const std::string& device_socket,
                      const std::string& args,
                      bool use_running_app,
                      int port) {
@@ -47,19 +48,19 @@ Status Device::SetUp(const std::string& package,

   std::string known_activity;
   std::string command_line_file;
-  std::string device_socket;
+  std::string known_device_socket = device_socket;
   std::string exec_name;
   if (package.compare("org.chromium.content_shell_apk") == 0) {
     // Chromium content shell.
     known_activity = ".ContentShellActivity";
-    device_socket = "content_shell_devtools_remote";
+    known_device_socket = "content_shell_devtools_remote";
     command_line_file = "/data/local/tmp/content-shell-command-line";
     exec_name = "content_shell";
   } else if (package.find("chrome") != std::string::npos &&
              package.find("webview") == std::string::npos) {
     // Chrome.
     known_activity = "com.google.android.apps.chrome.Main";
-    device_socket = "chrome_devtools_remote";
+    known_device_socket = "chrome_devtools_remote";
     command_line_file = kChromeCmdLineFileBeforeM33;
     exec_name = "chrome";
     status = adb_->SetDebugApp(serial_, package);
@@ -74,9 +75,10 @@ Status Device::SetUp(const std::string& package,

     if (!known_activity.empty()) {
       if (!activity.empty() ||
-          !process.empty())
+          !process.empty() ||
+          !device_socket.empty())
         return Status(kUnknownError, "known package " + package +
-                      " does not accept activity/process");
+                      " does not accept activity/process/device_socket");
     } else if (activity.empty()) {
       return Status(kUnknownError, "WebView apps require activity name");
     }
@@ -108,7 +110,7 @@ Status Device::SetUp(const std::string& package,

     active_package_ = package;
   }
-  this->ForwardDevtoolsPort(package, process, port, &device_socket);
+  this->ForwardDevtoolsPort(package, process, port, &known_device_socket);

   return status;
 }
diff --git a/chrome/test/chromedriver/chrome/device_manager.h b/chrome/test/chromedriver/chrome/device_manager.h
index d27aa50..6348ba6 100644
--- a/chrome/test/chromedriver/chrome/device_manager.h
+++ b/chrome/test/chromedriver/chrome/device_manager.h
@@ -25,6 +25,7 @@ class Device {
   Status SetUp(const std::string& package,
                const std::string& activity,
                const std::string& process,
+               const std::string& device_socket,
                const std::string& args,
                bool use_running_app,
                int port);
diff --git a/chrome/test/chromedriver/chrome_launcher.cc b/chrome/test/chromedriver/chrome_launcher.cc
index ca9d504..8b64565 100644
--- a/chrome/test/chromedriver/chrome_launcher.cc
+++ b/chrome/test/chromedriver/chrome_launcher.cc
@@ -476,6 +476,7 @@ Status LaunchAndroidChrome(
   status = device->SetUp(capabilities.android_package,
                          capabilities.android_activity,
                          capabilities.android_process,
+                         capabilities.android_device_socket,
                          switches.ToString(),
                          capabilities.android_use_running_app,
                          port);

I think the "solution" is for appium to fork chromedriver until the issue is fixed upstream.

@bootstraponline Are you still planning on forking chromedriver in the meantime? If you set up the fork, I can make the necessary changes.

I don't currently use appium at work so I'm not planning to fork
chromedriver. I still think it'd make sense for the appium devs to do so
though.

On Wed, Nov 4, 2015, 11:03 AM Matt Fritz [email protected] wrote:

@bootstraponline https://github.com/bootstraponline Are you still
planning on forking chromedriver in the meantime? If you set up the fork, I
can make the necessary changes.

—
Reply to this email directly or view it on GitHub
https://github.com/appium/appium/issues/4597#issuecomment-153810714.

Alright, thanks @bootstraponline

@sebv What are your thoughts on a chromedriver fork?

Hey, I have been using Appium for a while with great success (thx for great work) on my hybrid apps.

Now I have had to implement XWalk project ( https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview ) and I'm not able anymore to see my WEBVIEW context within appium .

I'm working on windows developping in JAVA.

My issue seems looking like current issue (https://github.com/appium/appium/issues/4597) or this one https://github.com/crosswalk-project/crosswalk-web-driver/issues/17

Do you guys have any updates for me regarding that issue ? Can I help on investigation ?
This issue is clearly a show stopper for us as it will makes all our past work on Appium useless.

Even an "ugly" workaround is acceptable for the moment. Thx for support

Hi @aorfevre.

This works for me:

  • @aluedeke chromedriver patch provided in this conversation
  • set androidDeviceSocket: my.package_devtools_remote capability
  • set chromedriverExecutable: path/to/patched/driver capability

I haven't any updates if there is something better now....

Thx @mpetrak for your fast reply!
Can you share the compiled chromedriver.exe ? Or shall compile it myself ?

Also, if my package is called : com.my.app; I shall named androidDeviceSocket as : com.my.app_devtools_remote ? is it right ?

@aorfevre

I have compiled and patched chromedriver for OS X only now.

Yes, com.my.app_devtools_remote should be the right name. If not sure Start android emulator / device, open your app and run these commands:

adb shell
shell@android$ cat /proc/net/unix |grep devtools_remote

Than you can see the right name. See https://crosswalk-project.org/documentation/android/android_remote_debugging.html for details.

@aorfevre. Did you manage to compile the exe. If yes, could you share it. I'm still confused how to compile it myself.

@madiska. Yes, there's a steep learning curve on compiling chromedriver from source. It's part of the chromium repo and uses the same build system.

General instructions
http://dev.chromium.org/developers/how-tos/get-the-code

Like @mpetrak I've only compiled and patched chromedriver for OS X. Here's what worked for me. Windows instructions should be similar:

1) Get depot_tools
Clone w/ git and add cloned directory to your PATH:
https://chromium.googlesource.com/chromium/tools/depot_tools.git

2) Get Gyp.
This is what the Chromium team recommends for non-Linux builds. There's a newer tool called GN recommended for Linux that may also work for Windows. Only Gyp worked for me on OS X.
Clone w/ git, then run the setup.py file w/ python
Instructions
https://github.com/enginetrouble/gyp-getting-started#how-to-build
Repo
https://chromium.googlesource.com/external/gyp.git

3) Get chromium src.
Don’t use git - you miss required build files that way. Instead use the tools fetch and gclient provided in depot_tools. Follow instructions from the link below. NOTE: Downloading chromium src can take several hours!
http://dev.chromium.org/developers/how-tos/get-the-code

4) Build chromedriver. Continue following instructions from the dev.chromium.org link. Where it tells you to build the chrome target, build the chromedriver target instead. I.e.

ninja -C out/Release chromedriver

Other helpful links:
GYP options
https://www.chromium.org/developers/gyp-environment-variables

Good luck!

@TimHambourger

Cheers. Actually I managed to get to some point, but then it was already 12 am. So I just went to bed. Took me a whole day to get all the stuff to work or not to throw errors. Hopefully building works.

hi @madiska & @TimHambourger ,
I'm facing big internet connexion issues and I still did not manage to clone Chromium repo.
Trying almost every night..

If @madiska you manage to build Windows Chrome version, I'll be glad to try it too.
In the meanwhile, I'll try again

@aorfevre & @TimHambourger

Sadly I'm unable to build it. It keeps getting stuck when I run the build command. No error message or anything. Google hasn't helped me also.

@aorfevre I'll keep trying but I think I won't be able to figure out what is causing this.

hi everybody,

a few weeks ago we investigated this question.
the main issue with _crosswalkwebdriver_ is - it uses xwalkOptions instead of chromeOptions in the desiredCapabilities object. so we patched appium to provide this object too.

i wrapped it to docker and you can use it on the windows pc too.

you can find code here - https://github.com/hamsterksu/appium-xwalk

sure you should specify androidDeviceSocket in your test. because xwalk uses different socket name than standard webview. and appium can't find it

according to driver path - you can specify it as run command parameter or from test too.

@hamsterksu we could add this capability directly into appium.
if users supply a { automationName: 'crosswalk' } desired capability to appium, it can call crosswalkwebdriver and pass in these modified capabilities.

does that sound great?

@Jonahss cool, should be useful.

if you plan to add it to the framework maybe you can patch https://github.com/appium/appium/blob/master/lib/devices/android/android-hybrid.js
and use another algorithm to find crosswalk socket in this case? but it will not be completed solution because you need to use crosswalkwebdriver instead of chromewebdriver.

so i think you have 2 options

  1. simple solution

    • just add { automationName: 'crosswalk' }

    • user(QA enginer) will specify androidDeviceSocket and chromedriverExecutable in test

  2. complex solution

    • add { automationName: 'crosswalk' }

    • patch android-hybrid.js to find correct unix socket

    • use crosswalkwebdriver instead of chromewebdriver

    • version of crosswalkwebdriver should be configurable

i think option 2 is too complicated

what do you think?

@Jonahss
Everything moving forward with crosswalk integration to Appium is welcome on my side.
Complex solution from @hamsterksu looks like the target. :)

Awesome work.
@hamsterksu's complex solution looks awesome. Appium 1.5's new architecture makes adding (and modifying) new drivers very easy. Forking appium-android-driver into a new module is pretty easy :) Then crosswalk can be added instead of chromedriver.

Right now, the main Appium contributors have a lot on their plate (getting 1.5 out, new Uiautomatior2 driver, new XCUITest driver) but this is something we'd like to see. Is anyone willing to work on this? We can provide guidance when it comes to the Appium codebase.

@Jonahss I can take a crack at it. Just to clarify:

  1. Fork appium-android-driver to appium-crosswalk-driver and modify chromedriver references to reference crosswalkdriver. Allow different crosswalkdriver versions
  2. Add crosswalk automationName config options to Appium
  3. Modify android-hybrid.js to look for the Crosswalk unix socket and webview name

Anything else before I dig in?

@mattfritz my perspective is that it should not be a fork of appium-android-driver but a subclass of it (i.e., don't duplicate code across the packages). your other two points look right on to me!

Hi @madiska & @aorfevre

Have you guys managed to build the chromedriver.exe?

@ITKarel I managed to build one, but not sure if it working. I will try to get it to work like Tim described and then upload the files, but first need to get it to work.

@TimHambourger Heia, Can you give us a working example how you used the new chromedriver. Some step seem to missing for me.

@mattfritz Did you make any progress on your "digging"?

I'm thinking of looking into it myself because the last comment is 2 weeks old. Let me know if you managed to get it working properly.

Would be nice to get a short response at least. Is a "fix" planned for this?

I was able to get it working with chromedriver. I had to patch chromedriver as well as android-hybrid.js For me using crosswalkwebdriver is not a viable solution as it has a dependency on docker to work on Windows.

@ITKarel What did you change in the android-hybrid.js and if you don't mind can you post the chromedriver somewhere.

@madiska I will post my complete solution a bit later today.

Thanks, @ITKarel ! That's awesome!

I added my rebuild chromedriver.exe as well as instructions on how to use. https://github.com/ITKarel/ChromeDriver

@ITKarel You are a lifesaver. Will try it out tommorow at work. :dancer:

Did you plan a Linux/Mac build? ;D

@chOOnz I took a look and the simple solution from @hamsterksu seems like the better option because crosswalkdriver released their binaries without naming conventions (e.g. the xwalk 16 driver). I haven't had time to work on it because of the holidays, but if you want to look at it and beat me to the punch that works too.

The complicated solution will probably not have a good way to specify a version, but going that direction would involve creating an Appium plugin for crosswalkdriver (like chromedriver) and integrating it into the android plugin.

I'l let you know if I have other updates later this week. Cheers!

Thanks a lot, @ITKarel ! This worked very well for me!

@hypery2k unfortunately I can only do a windows build. For Linux you can always try the xwalkdriver as suggested by @hamsterksu

@hamsterksu you mentioned that you wrapped crosswalkwebdriver to docker and you can use it on the windows pc too. Does this require docker to be installed on the PC?

@ITKarel Great work! Unfortunately I'm working on Linux, too, like @hypery2k
I will look into it within the next week and maybe I will be able to build the chromedriver for Linux/Mac. I will post here when I got any updates on that.

@mattfritz I didn't have any time either but I will look into it someday when I got some sparetime from actual work.

@ITKarel

Heya could you also upload the working appium setup example. I wanna see if I'm doing something wrong or there is another issue with the app. Currently I'm able to find the webview, but the tests don't do anything that.
So I'm wondering if I'm doing something wrong in the setup part.

Edit

I managed to get it to work. Thanks mate.

Hey guys, I'd really appreciate a chromedriver fix for a mac if you get a chance to build one or show me how to do it that'd be great too @chOOnz
@mattfritz any news on adding the fix to Appium? @TimHambourger would you be able to share your patched Chromedriver for Mac by any chance?

I am also stuck with a same issue and would like to know how to get the chromedriver fix for mac.
@piotrekkmt @chOOnz @TimHambourger

@mayureshshirodkar Here's a mac fix for the chromedriver version 2.20. Also added in the android-hybrid.js file and some how to steps for the chromeOptions capabilities.
https://github.com/piotrekkmt/chromedriver-appium

Thanks for listing out the steps @TimHambourger !

Thanks a lot @piotrekkmt @TimHambourger for the chromedriver. Works!

Thanks @piotrekkmt , works great!

@jlipps @Jonahss i am not able to find android-hybrid.js file on Appium 1.5. Need to edit the androidHybrid.listWebviews method in ..\Appium\node_modulesappium\lib\devicesandroidandroid-hybrid.js to push {package name}_devtools_remote to the webviews list.

@piotrekkmt @souly1 @TimHambourger have you'll tried Crosswalk Apps on appium 1.5?

@piotrekkmt @souly1 @TimHambourger @jlipps @Jonahss

This fix doesn't work for me anymore since Appium 1.5. I don't know wether it's because of the missing android-hybrid.js or not.

Does anyone still use this workaround and got it working with Appium 1.5?

Sorry chOOnz, haven't tried 1.5from the notes of the release:
Appium 1.5 is a complete rewrite of Appium from the ground up.
1.4.16 is the latest version i worked with.

@souly1 Thanks! I switched back to 1.4.16 in order to be able to modify the files I need to. I have no idea where the code went in 1.5. :D

I got a patched version of the chromedriver for linux which is working with crosswalk. Is anyone interested in using it?

yes, please
I'am interested in chromedriver for linux

@didlich Here you go: https://github.com/chOOnz/xwalk-chromedriver

Have fun with it! :-)

@chOOnz thanks

Hi there. I have gone here: https://github.com/piotrekkmt/chromedriver-appium and followed instructions (For Mac). I can now see the Web context:
["NATIVE_APP", "CHROMIUM"]

However, when I try to switch to chromium I get the following error in the server logs:

info: Chromedriver: Changed state to 'stopped'

error: Chromedriver: Chromedriver exited unexpectedly with code null, signal SIGTERM

warn: Chromedriver for context CHROMIUM stopped unexpectedly
warn: Chromedriver quit unexpectedly, but it wasn't the active context, ignoring

error: Chromedriver: Error: An error occurred (Original error: chrome not reachable
  (Driver info: chromedriver=2.18.343837 (52eb4041461e46a6b73308ebb19e85787ced4281),platform=Mac OS X 10.11.4 x86_64))
    at JWProxy.command$ (lib/proxy.js:149:15)
    at tryCatch (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:294:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at bound (domain.js:254:14)
    at GeneratorFunctionPrototype.runBound (domain.js:267:12)
    at run (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:89:39)
    at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:100:28
    at process._tickDomainCallback (node.js:381:11)
 { [Error: An error occurred (Original error: chrome not reachable
  (Driver info: chromedriver=2.18.343837 (52eb4041461e46a6b73308ebb19e85787ced4281),platform=Mac OS X 10.11.4 x86_64))]
  status: 100,
  value: { message: 'chrome not reachable\n  (Driver info: chromedriver=2.18.343837 (52eb4041461e46a6b73308ebb19e85787ced4281),platform=Mac OS X 10.11.4 x86_64)' },
  httpCode: 200 }

If I set the following:

'chromedriverExecutable' => '/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver',

and rerun I get this error instead

Selenium::WebDriver::Error::UnknownError:
       Can't stop process; it's not currently running
error: Could not proxy command to remote server. Original error: connect ECONNREFUSED

info: --> GET /wd/hub/status {}
info: JSONWP Proxy: Proxying [GET /wd/hub/status] to [GET http://127.0.0.1:9515/wd/hub/status] with body: {}

info: [debug] Stopping logcat capture

Not sure what I might be doing wrong. Hoping someone can help as I am stuck with my Android automation until I can resolve this.

Thanks in advance.

Try and replace your appium-hybrid.js file, with the one @ITKarel has provided. See if it works.

@mayureshshirodkar no luck. I replaced it but still getting the same error. :(

@danqa which Appium version are you using? The chromedriver fix on my github works with the latest 1.4 version. But on 1.5 the appium-hybrid.js doesn't do the trick and that seems like your problem. The context displayed is Chromium instead of the webview inside of it.

Was anyone able to find where did the context handling for hybrid apps in appium-hybrid.js go in 1.5?
On the other hand, is there a different fix (less hacky) for hybrid apps based on Crosswalk?

@peterpoliwoda I am using 1.4.16. I updated the appium-hydrid.js and dowloaded the latest version of chromdriver but see CHROMIUM not WebView. Can you point me to your chromedriver fix?

Update: I cleaned out appium from my machine and reinstall version 1.4.16 via npm. I then followed all the information on @peterpoliwoda github for the fix.

When I run I now see 2 contexts:
["NATIVE_APP", "WEBVIEW_com.my.app_devtools_remote"]

So I do:
driver.set_context('WEBVIEW_com.my.app_devtools_remote')

But at that point the system hangs. I see the following in the logs:

info: Chromedriver: [STDOUT] Starting ChromeDriver 2.20.370386 (91c49fb9369f1323d7022402d86aac62b4244cb4) on port 9515 Only local connections are allowed. info: JSONWP Proxy: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body info: JSONWP Proxy: Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Mac OS X\",\"version\":\"10.11.4\"}}}" info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.my.app","androidUseRunningApp":true,"androidDeviceSerial":"192.199.199.101:5555"}}} info: [debug] Didn't get a new command in 60 secs, shutting down... info: Shutting down appium session info: [debug] Pressing the HOME button

I have no waits in my code so I am not sure why its not working.

@danqa can you please try with appium 1.5.1 the latest ..

@saikrishna321

with version 1.5.1 it finds the CHROMIUM webview but when I try to switch to it it hangs then fails:

[debug] [AndroidDriver] Available contexts: ["NATIVE_APP","CHROMIUM"] [debug] [AndroidDriver] Connecting to chrome-backed webview context 'CHROMIUM' [debug] [Chromedriver] Changed state to 'starting' [Chromedriver] Set chromedriver binary as: /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver [Chromedriver] Killing any old chromedrivers, running: ps -ef | grep /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver | grep -v grep |grep -e '--port=9515\(\s.*\)\?$' | awk '{ print $2 }' | xargs kill -15 [Chromedriver] Successfully cleaned up old chromedrivers [Chromedriver] Spawning chromedriver with: /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver --url-base=wd/hub --port=9515 --adb-port=5037 [Chromedriver] [STDOUT] Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 9515 Only local connections are allowed. [JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Mac OS X\",\"version\":\"10.11.4\"}}}" [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.my.app","androidUseRunningApp":true,"androidDeviceSerial":"192.168.99.101:5555"}}} [JSONWP Proxy] Got response with status 200: {"sessionId":"16581f2900fd227d1985aa5d2c9d5bdd","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=M... [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.my.app","androidUseRunningApp":true,"androidDeviceSerial":"192.168.99.101:5555"}}} [JSONWP Proxy] Got response with status 200: {"sessionId":"a03f1a6212923daf9894649a753d2b64","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=M... [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.my.app","androidUseRunningApp":true,"androidDeviceSerial":"192.168.99.101:5555"}}} [JSONWP Proxy] Got response with status 200: {"sessionId":"b5af6a6a03939bc5ee4e92a39742c129","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=M... [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.my.app","androidUseRunningApp":true,"androidDeviceSerial":"192.168.99.101:5555"}}} [JSONWP Proxy] Got response with status 200: {"sessionId":"6a0e6860696383c08bb0dfb32b1030bb","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=M... [Chromedriver] Chromedriver exited unexpectedly with code null, signal SIGTERM [debug] [Chromedriver] Changed state to 'stopped' [Chromedriver] Error: An error occurred (Original error: chrome not reachable (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.4 x86_64)) at JWProxy.command$ (lib/proxy.js:139:15) at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) at run (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:104:47) at /usr/local/lib/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:115:28 at flush (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/$.microtask.js:19:5) at nextTickCallbackWith0Args (node.js:415:9) at process._tickCallback (node.js:344:13) { [Error: An error occurred (Original error: chrome not reachable (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.4 x86_64))] status: 100, value: { message: 'chrome not reachable\n (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.4 x86_64)' }, httpCode: 200 } [MJSONWP] Encountered internal error running command: Error: An error occurred (Original error: chrome not reachable (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.4 x86_64)) at JWProxy.command$ (lib/proxy.js:139:15) at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) at run (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:104:47) at /usr/local/lib/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:115:28 at flush (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/$.microtask.js:19:5) at nextTickCallbackWith0Args (node.js:415:9) at process._tickCallback (node.js:344:13) [HTTP] <-- POST /wd/hub/session/67411f3f-4c17-4184-b0f9-48c9d99d7657/context 500 241883 ms - 346

Still stuck. Works fine for all my iOS stuff.

@imurchie can you please on this

Anyone have any ideas? I'm stuck at this point in my android development for automation.

*_EDIT *_*
Even if I don't get why, but my tests are now running after adding this desiredCapability : autoWebview = true


Dear all,

Has someone tried docker provided by @hamsterksu ???

I working on Windows for dev and for Continous integration, we do have Linux servers so Docker solution is a must for us.
I develop my e2e tests on JUnit.

What is working :

  • docker is running on windows
  • phone is accessible from docker
  • app is installed on device remotly
  • I see more context now, NATIVE_APP and CHROMIUM.

I was expecting a WEBVIEW context.

Now my issue is that I can't find also any element from my webview.

*_Does anyone has an idea or suggestion ? *_

Here my config

String appLoc = "/home/apks/";
String appName = "android-armv7-debug.apk";
String myPackage = "com.mypackage";
String appiumUri = "http://192.168.99.100:4723/wd/hub";


DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android");
capabilities.setCapability("platformVersion", "4.4.2");
capabilities.setCapability("app", appLoc+appName);
capabilities.setCapability(MobileCapabilityType.APP_PACKAGE,myPackage);
capabilities.setCapability(MobileCapabilityType.TAKES_SCREENSHOT,"true");
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT,15);

// for xwalk socket
capabilities.setCapability("androidDeviceSocket",myPackage+"_devtools_remote");

driver = new AndroidDriver<>(new URL(appiumUri), capabilities);

I access to element with xpath locators. Element is visible when error occurs

public static By getAgreementsBtn () {
    return By.xpath("//button[@ng-click='termOfUseToogle()']") ;
}
Tests in error:
  test.java.com.rizze.citizzeye.AuthenticationWebViewTest: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace informatio
n)(..)

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

thank everyone for support

Has there been any progress on this? I upgraded to Appium 1.5.2 which shows in the change logs support for chrome browser but it still is not allowing a switch the the Chromium web view. Any help greatly appreciated.

Is there a way to run Appium with NOT PATCHED Chromedriver to test crosswalk-based application? I've tried Appium 1.5.2 with no success (_{"message":"chrome not reachable\n (Driver info: chromedriver=2.21.371461 ...}_) after correct switching to CHROMIUM context. androidDeviceSocket was set correctly.

It is important to me to webdriver be not patched, since such driver cannot be used for remote testing in cloud services like SauceLabs. Thanks in advance for reactions.

As far as I know there has been no movement on this. 1.5.2 supports chrome and chromium, but only through the stock ChromeDriver (version 2.2.1).

The only issue I can find in ChromeDriver is https://bugs.chromium.org/p/chromedriver/issues/detail?id=749 if you'd like to get on there and try to get some interest going.

Thanks for pointing out the ChromeDriver issue, writing there is the least I can try.

I am on 1.5.2 with Appium Java Client 4.0.0. This issue still persists on an Android App with Webview for Facebook, Twitter & Gmail authentications. Appium is not able to find the webviews (doesn't list the context) on both emulator and real device.

@kskrishnan is your app built with CrossWalk?

@chOOnz is it possible for you to re-upload the linux xwalk webdriver ? thanks for helping btw

Update (24 Jun, 2016):
latest patch version can be found on https://github.com/rokkknrollla/appium-android-xwalk-driver-patch

Hi everyone! Based on this solution: https://github.com/piotrekkmt/chromedriver-appium - I managed to patch Appium 1.5.3 (with Appium Java Client 4.0.0) so it now can recognize Cordova (CrossWalk) WebViews on macOS

I guess this patch would work with any other OS as well but you'll need chromedriver binary for that OS (i.e. Windows: https://github.com/ITKarel/ChromeDriver)

The steps as follows:

Install Appium 1.5.3 via NPM

$ npm install -g appium

Patch appium-android-driver

$ cd /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/
$ patch -p1 lib/webview-helpers.js /path/to/patch/file/webview_helpers_cordova_suppport.patch

Rebuild Appium Android Driver (run command in module root directory)

$ npm install

Copy patched ChromeDriver into module directory

$ cd /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac/
$ cp -i /path/to/patched/file/chromedriver .
overwrite ./chromedriver? (y/n [n]) y

Start Appium as usual

$ appium
[Appium] Welcome to Appium v1.5.3 (REV 02ccb7dcfd188d33795d19a2846c937c93851ff8)
[Appium] Appium REST http interface listener started on 0.0.0.0:4723

Add capabilities as follows

String ANDROID_APP_PACKAGE = "com.example.app.package";
String ANDROID_DEVICE_SOCKET = ANDROID_APP_PACKAGE + "_devtools_remote";
capabilities.setCapability("androidDeviceSocket", ANDROID_DEVICE_SOCKET);
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("androidDeviceSocket", ANDROID_DEVICE_SOCKET);
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

@rokkknrollla Tried the Solution you provided above, Din't work for me.

@mayureshshirodkar any issues or errors in Appium Server log?

can you post the output of $ adb shell "cat /proc/net/unix" | grep devtools ?

Log when i tried and executed your solution:
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb with args: ["-P",5037,"-s","LGD325fa08c844","shell","cat","/proc/net/unix"]
[debug] [AndroidDriver] Found webviews: []
[debug] [AndroidDriver] Available contexts: ["NATIVE_APP"]
[debug] [AndroidDriver] Shutting down Android driver

Log when i used Patched xwalk Appium 1.4.16:
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s LGD325fa08c844 shell "cat /proc/net/unix"
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.eab.se
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.eab.se

Can you please post $ adb shell "cat /proc/net/unix" | grep devtools (when app is running on device)? Need to check if process name for your apps is different from template I was using

Here you go: Open the App and ran the command adb shell "cat /proc/net/unix" | grep devtools:

38c98609713b:node_modules shirodkm$ adb shell "cat /proc/net/unix" | grep devtools
00000000: 00000002 00000000 00010000 0001 01 49368 @com.eab.se_devtools_remote

Seems fine. Can you attach /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/build/lib/webview-helpers.js to see if it was recompilled correctly?

Heres the attachment changed to .txt:
webview-helpers.txt

@mayureshshirodkar all the changes seem to be in place, need to investigate further

@rokkknrollla Checking on my end too. Whats the chromedriver that you are using?

@mayureshshirodkar patched chromedriver, the one I linked in my post (build by @piotrekkmt)

Expected output should be like this:

[debug] [AndroidDriver] Getting a list of available webviews
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /usr/local/Cellar/android-sdk/24.4.1_1/platform-tools/adb with args: ["-P",5037,"-s","HT578WV00270","shell","cat","/proc/net/unix"]
[debug] [AndroidDriver] Found webviews: ["WEBVIEW_undefined"]
[debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_undefined"]

WEBVIEW_undefined is because we are unable to get actual process ID in webview-helpers.js but it works fine for me

@outEduardoSilva I reuploaded the patched chromedriver for linux: https://github.com/chOOnz/xwalk-chromedriver

Keep in mind this fix is only applicable on Appium version 1.4.16! When you need to patch Appium version 1.5.3 please look at @rokkknrollla 's fix posted above.

Updated patch file to support multiple WebViews.

WEBVIEW_org.fxclub.libertex.tablet_1408450_
WEBVIEW_org.fxclub.libertex.tablet_1408709_
WEBVIEW_org.fxclub.libertex.tablet_1408706_

Though in order to switch from one webview to another you need to switch to NATIVE context first. Otherwise Appium will crash

driver.context("WEBVEIW_1");
driver.context("NATIVE_APP");
driver.context("WEBVEIW_2");

UPDATE: actual switching between webviews doesn't seem to work though
UPDATE: removed multi-webviews support from patch

Hi @rokkknrollla

I have followed the setp you listed above to install the patch. I then run my tests with the following caps set:

caps = {
    'platformName' => 'Android',
    #'platformVersion' => '6.0.0', 
    'app' => 'app',
    'unicodeKeyboard' => 'true',
    'deviceName' => 'Samsung Galaxy S6 - 6.0.0 - API 23 - 1440x2560',
    'chromedriverExecutable' => '/usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver',
    'androidDeviceSocket' => 'myapp_devtools_remote',
    'fullReset' => 'true',
    'autoWebview' => 'true',
  }

I see the app load and when I print out the current webviews I see

["NATIVE_APP", "WEBVIEW_myapp_devtools_remote"]

But then the app immediately shuts down and I get this rather unhelpful error:

Selenium::WebDriver::Error::ServerError:
status code 500

My app was launching prior to the patch so I am wondering if this possible related to the patch. Any idea how I might get some more meaningful information from the server so I can see what the actual 500 is?

@danqa I never used 'autoWebview' => 'true' capability so I tried to add it and run tests and got an error on driver initialisation step:

org.openqa.selenium.WebDriverException: No such context found. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 9.89 seconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'xxx', ip: 'xxx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.5', java.version: '1.8.0_65'
Driver info: io.appium.java_client.android.AndroidDriver

Try to remove this capability and switch contexts manually after driver has been successfully initialized
Example for Java:

            Set<String> contextHandles = driver.getContextHandles();
            List<String> webviews =
                    contextHandles.stream().filter(
                            p -> StringUtils.startsWith(p,"WEBVIEW")
                    ).collect(Collectors.toList());
            String webview = webviews.get(0);
            driver.context(webview);

Also I can not see ChromeOptions caps. It is necessary to make it properly work with patched chromedriver

capabilities.setCapability("androidDeviceSocket", ANDROID_DEVICE_SOCKET);
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("androidDeviceSocket", ANDROID_DEVICE_SOCKET);

@rokkknrollla I'll try that. Only question is that I am using the Ruby bindings (appium_lib). Will this work
with those bindings?

@danqa it should work, we just need to find a way to set it correctly

I did some search in Appium Android Driver source code and here is what I've found:

helpers.defaultWebviewName = function () {
  return WEBVIEW_BASE + this.opts.appPackage;
};

with 'autoWebview' => 'true' it uses default WebView name which is different from what we are getting after patch

I guess I can make changes into patch so webview name after patch will match default template

@rokkknrollla If you would patch that I would be quite gratefully. Until then, I will load then switch for now. Thanks for the help. Much appreciated.

Does anyone have an example of how to setChromeOption in ruby.? I can only find examples in Java.

@danqa can you revert old patch and try to patch it again?
https://github.com/rokkknrollla/appium-android-xwalk-driver-patch/blob/master/webview_helpers_cordova_suppport.patch

it is only one line change

This seems to be the way for anyone who needs it:

chromeOptions' => {
        'androidDeviceSocket' => 'myapp_devtools_remote'
    }

Seems to be working now as when I switch contexts and print out the context I'm on its the WEBVIEW one. Thanks so much for this.

@rokkknrollla sure I'll give it a try in a bit and see if the update works for that option. Thanks again for the help.

@rokkknrollla fyi the 'autoWebview' => 'true' setting works. Thanks again for this patch.

Hi,

I have tried below things to rebuild chromedriver.exe to support for XWalk WebViews, But no luck found yet.

1) Replace ..\Appium\node_modulesappium\node_modulesappium-chromedriver\chromedriver\win\chromedriver.exe with the chromedriver.exe provided here.
https://github.com/ITKarel/ChromeDriver/blob/master/chromedriver.exe

2) Edit the androidHybrid.listWebviews method in ..\Appium\node_modulesappium\lib\devicesandroidandroid-hybrid.js to push {package name}_devtools_remote to the webviews list. The modified android-hybrid.js is provided here.
https://github.com/ITKarel/ChromeDriver/blob/master/android-hybrid.js

3) I am using automation with C# .net language, So I have set below capabilities
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("deviceName", deviceName);
capabilities.SetCapability("platformName", "Android");
capabilities.SetCapability("autoWebview", "true");
capabilities.SetCapability("apppackage", "com.xyz");
capabilities.SetCapability("appActivity", "com.xyz");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddAdditionalCapability("androidDeviceSocket", "com.xyz");
capabilities.SetCapability(ChromeOptions.Capability, chromeOptions);

4) Created the webdriver object:
IWebDriver driver = RemoteWebDriver(new Uri(appConfig.ServerAddress),capabilities );
and also tried below driver
AppiumDriver driver = AndroidDriver(new Uri(appConfig.ServerAddress),capabilities );

but when I am trying to get current windows handle from driver it is throwing me NotImplementedException
string mainWindowHandler = driver.CurrentWindowHandle;
where as it should give me window like "CDWindow-abcdef-....".

I tried to install Appium 1.5.3. Please suggest what I am missing?

Thanks,
Mohini

@MohiniR Even i am getting similar issues with Appium version 1.5.3 .
But the fix by ITKarel works fine for me on Appium 1.4.16. So right now stuck with that version of Appium. Right now you can use 1.4.16.
Will update this space if i get it working on Appium 1.5.3.

@MohiniR scripts you mentioned in posts are working only with 1.4.x Appium

For 1.5.3 you need to try different solution: https://github.com/appium/appium/issues/4597#issuecomment-226725499

@mayureshshirodkar and @rokkknrollla , I tried with 1.4.16 also but it is not working with same also.

@MohiniR I believe you need to use driver.Contexts to get list of available contexts (native, webviews etc)

@rokkknrollla and @mayureshshirodkar
With patch support available in https://github.com/ITKarel/ChromeDriver I am able to get the context views but my application contains the popup(plugins rendered by javascript example 'login with google')

When i click on the 'login with google' on the page it takes me to Gmail login page which
gets opened in new popup. And I am not able to switch to that new popup window and even getWindowHandles()

I tried to set below capabilities :
a. setWebContentsDebuggingEnabled : true
b. --always-authorize-plugins : true

@MohiniR yes, it's known issue - you can work only with first webview, but unfortunately, I haven't found solution yet

I've got both solutions working for Appium 1.5.3 on OS X. The one for #4797 the key is not to use {autoWebview : true} and set androidDeviceSocket name. Be aware when selecting the webview by name, to use "CHROMIUM" rather than "WEBVIEW" as prefix. Would be great is someone could re upload the chromedriver for Linux since the file no longer exists.
The eduramiba's workaround walks fine in Linux. androidDeviceSocket is not need it nor the autoWebview.

@rokkknrollla Hi there. They just released Xcode 8 and iOS 10. In order to work with that I needed to update to Appium1.6.0Beta. However, that breaks your patch as it was for 1.5.3. Would you be able to provide an updated patch for the Beta version?

This issue is over 2 years old: https://bugs.chromium.org/p/chromedriver/issues/detail?id=749 I wonder if anything can be done to get the chromium team to address this. It literally blocks anyone with crosswalk apps on android. Thank goodness for the patches.

Can confirm that the 1.5.3 patch doesn't work with the 1.6.0 beta. :( Ran through the patch step then ran tests but it errors out with a 500:

[MJSONWP] Calling AppiumDriver.setContext() with args: ["WEBVIEW_com.app.st... [debug] [AndroidDriver] Getting a list of available webviews [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running /Users/me/Library/Android/sdk/platform-tools/adb with args: ["-P",5037,"-s","192.168.57.101:5555","shell","cat","/proc/net/unix"] [debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_com.app_22310"] [HTTP] <-- POST /wd/hub/session/ada74226-6275-47c0-acd0-06c79f2d2032/context 500 77 ms - 109 [HTTP] --> DELETE /wd/hub/session/ada74226-6275-47c0-acd0-06c79f2d2032 {} [MJSONWP] Calling AppiumDriver.deleteSession() with args: ["ada74226-6275-47c0-acd0-0... [debug] [AndroidDriver] Shutting down Android driver [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running /Users/me/Library/Android/sdk/platform-tools/adb with args: ["-P",5037,"-s","192.168.57.101:5555","shell","am","force-stop","com.app.op"] [debug] [ADB] Pressing the HOME button [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running /Users/me/Library/Android/sdk/platform-tools/adb with args: ["-P",5037,"-s","192.168.57.101:5555","shell","input","keyevent",3] [debug] [ADB] Uninstalling com.app.op [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running /Users/me/Library/Android/sdk/platform-tools/adb with args: ["-P",5037,"-s","ipaddress","shell","am","force-stop","com.app.op"] [debug] [ADB] Running /Users/me/Library/Android/sdk/platform-tools/adb with args: ["-P",5037,"-s","ipaddress","uninstall","com.ap.op"] [ADB] App was uninstalled [debug] [AndroidBootstrap] Sending command to android: {"cmd":"shutdown"} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"OK, shutting down"} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Closed client connection [debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: numtests=1 [debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=. [debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner [debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: test=testRunServer [debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap [debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: current=1 [debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: 0 [debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream= [debug] [AndroidBootstrap] [UIAUTO STDOUT] Test results for WatcherResultPrinter=. [debug] [AndroidBootstrap] [UIAUTO STDOUT] Time: 12.606 [debug] [AndroidBootstrap] [UIAUTO STDOUT] OK (1 test) [debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: -1 [debug] [AndroidBootstrap] Received command result from bootstrap [debug] [UiAutomator] Shutting down UiAutomator [debug] [UiAutomator] Moving to state 'stopping' [debug] [UiAutomator] UiAutomator shut down normally [debug] [UiAutomator] Moving to state 'stopped' [debug] [ADB] Attempting to kill all uiautomator processes [debug] [ADB] Getting all processes with uiautomator [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running /Users/me/Library/Android/sdk/platform-tools/adb with args: ["-P",5037,"-s","ipaddress","shell","ps","uiautomator"] [ADB] No uiautomator process found to kill, continuing... [debug] [UiAutomator] Moving to state 'stopped' [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running /Users/me/Library/Android/sdk/platform-tools/adb with args: ["-P",5037,"-s","ipaddress","shell","am","force-stop","io.appium.unlock"] [debug] [Logcat] Stopping logcat capture [Appium] Removing session ada74226-6275-47c0-acd0-06c79f2d2032 from our master session list [debug] [MJSONWP] Received response: null [debug] [MJSONWP] But deleting session, so not returning [MJSONWP] Responding to client with driver.deleteSession() result: null [HTTP] <-- DELETE /wd/hub/session/ada74226-6275-47c0-acd0-06c79f2d2032 200 2311 ms - 76```

@imurchie would it be possible for you or one of the other guys on the appium team to take the @rokkknrollla patch above, modify it and make it part of appium (as part of the self contained build). I know its not ideal, but the patch is small and with that issue having been open with the chromium guys for over 2 year I have my doubts they will ever address it. Otherwise, every time there is an upgrade this will be a problem for everyone using crosswalk.

@danqa hi! yes, I will eventually come around and try and modify it to support 1.6.0 - we do need to test iOS as well, but it really needs some serious polishing before we can make it a part of Appium

'autoWebview' and multiple webviews issues need to be sorted first because at the moment patch fixes one thing and breaks another :)

@rokkknrollla I hear ya. Thanks for working on this.

i agree with @imurchie ...Appium dev team could integrate this patch with Appium. As more Crosswalk Apps are being used. @jlipps @Jonahss

Sorry, we just don't have the bandwidth to maintain a patched version of chromedriver

That's very disappointing. I totally understand the lack of resources but basically the chromium team wont patch it (over 2 years) and there is no real work around. With crosswalk becoming a more popular way to build apps not sure what this means for testing hybrid apps in Android.

@danqa I understand that it's disappointing. I'm disappointed that the Android team is apparently not listening to a huge set of its developers. If someone else were to maintain a patched version of Chromedriver, then I'd consider making it an alternative download, hidden behind a capability or server flag or something like that.

FYI... I have reverted back to Appium 1.5.3 and reapplied @rokkknrollla patch but it is no longer working. Seeing the following in the logs

[MJSONWP] Calling AppiumDriver.setContext() with args: ["WEBVIEW_com.myapp...
[debug] [AndroidDriver] Getting a list of available webviews
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/me/Library/Android/sdk/platform-tools/adb with args: ["-P",5037,"-s","192.168.57.101:5555","shell","cat","/proc/net/unix"]
[debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_com.myapp_12453"]
[HTTP] <-- POST /wd/hub/session/12b72a6a-3754-4c33-b9fe-3ec85c9b5987/context 500 89 ms - 109
[HTTP] --> DELETE /wd/hub/session/12b72a6a-3754-4c33-b9fe-3ec85c9b5987 {}
[MJSONWP] Calling AppiumDriver.deleteSession() with args: ["12b72a6a-3754-4c33-b9fe-3...
[debug] [AndroidDriver] Shutting down Android driver

But it 500s when POSTing to context and there is no stack trace of the error.

How are you switching context?
Are you using AutoWebView, If yes try taking it off and manually try to switch to webview.

@mayureshshirodkar Not using AutoWebView. Manually switching back and forth.

driver.set_context('WEBVIEW_com.app_12435')

Regarding the usage of patched chromedriver, one should be able to use a patched chromedriver from appium server args giving path to patched chromedriver.
I don't have chrome source code checked out to patch and try out.

@jlipps I have compiled crosswalk webdriver binaries for mac and windows
These are based of chromedriver v2.21 and crosswalk-20 branch for mac and windows.
https://github.com/rkavalap/crosswalk-web-driver/releases.

These binaries have been working for me with appium 1.3.5 with minor changes suggested by @hamsterksu above. I just didn't get enough time to completely fix all the changes for the latest appium. Each of the minor modifications ended up as bugs in appium repositories aiding in my investigations further. Considering the async nature of appium source code, its harder to debug, ide support for source maps is poor. all suggestions are welcome for debugging support.

Based on my observations there are fixes required in both appium's packages as well as chromedriver. The amount of change itself will be very less, but is very impacting.

It would be nice to have a meetup considering we didn't have one for more than 6 months.

Fyi.... I spoke to Saucelabs and asked them if they would be willing to support a patched version of chromedriver for Appium since they are one of the main drivers of Appium, but they believe that its is something that either the crosswalk-team should do or the chromium team finally fixes it (can't say I disagree). I have reached out to the crosswalk team to see if they might be willing to do that but am not holding my breath. IMO if someone on this thread builds a patch and pushes it to the chroumium team as a PR it should get merged and then they would need to support it going forward. Other than that I see very limited options in getting this resolved.

Patch for chromedriver repo currently in code review.
https://codereview.chromium.org/2375613002/

Appropriate change in appium-android-driver package also needs to be made for identifying the correct webview.

@danqa Hi,danqa. I try to switch to webview in crosswalk view but fail,and report useless error:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Can't stop process; it's not currently running (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 96 milliseconds
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'ehang-own', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'i386', os.version: '3.16.0-30-generic', java.version: '1.8.0_101'
Driver info: io.appium.java_client.AppiumDriver
Capabilities [{appPackage=com.app.ehang.copter, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=A10ABMQPGJKM, platform=LINUX, deviceUDID=A10ABMQPGJKM, appActivity=com.app.ehang.copter.activitys.MainActivity, desired={appActivity=com.app.ehang.copter.activitys.MainActivity, appPackage=com.app.ehang.copter, androidDeviceSocket=com.app.ehang.copter_devtools_remote, chromeOptions={args=[], extensions=[], androidDeviceSocket=com.app.ehang.copter_devtools_remote}, platformName=Android, deviceName=A10ABMQPGJKM}, platformVersion=5.1, webStorageEnabled=false, locationContextEnabled=false, takesScreenshot=true, javascriptEnabled=true, androidDeviceSocket=com.app.ehang.copter_devtools_remote, chromeOptions={args=[], extensions=[], androidDeviceSocket=com.app.ehang.copter_devtools_remote}, platformName=Android}]
Session ID: 8a8b8a23-f46b-42c6-88f8-62f886ce1ae5
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:81)
at io.appium.java_client.AppiumDriver.context(AppiumDriver.java:487)
at h5test.h5.test01(h5.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
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:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Here is my code:
` static AppiumDriver driver;

@Before
public void setUp() throws Exception
{
    String appiumUri = "http://localhost:4723/wd/hub";
    String packname = "com.app.ehang.copter";
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("deviceName", "A10ABMQPGJKM");

// capabilities.setCapability("platformVersion", "3.1.6");
capabilities.setCapability("appActivity", "com.app.ehang.copter.activitys.MainActivity");
capabilities.setCapability("appPackage", packname);

    String ANDROID_DEVICE_SOCKET = packname + "_devtools_remote";
    capabilities.setCapability("androidDeviceSocket", ANDROID_DEVICE_SOCKET);
    ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.setExperimentalOption("androidDeviceSocket", ANDROID_DEVICE_SOCKET);
    capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

    driver = new AppiumDriver(new URL(appiumUri), capabilities);
}
@After
public void teardown()
{
    driver.quit();
}
@Test
public void test01() throws InterruptedException
{
    Thread.sleep(30000);
    Set<String> contextNames = driver.getContextHandles();
    for (String contextName : contextNames)
    {
        System.out.println(contextName);

        if(contextName.contains("WEBVIEW"))
        {
            driver.context(contextName);

            System.out.println(driver.findElementById("modename").getText());                   
        }
    }       
}`

It will print two view: "NATIVE_APP" and "WEBVIEW_",but can't switch to "WEBVIEW_",it's there any wrong with my code?

I replace chromedriver_32 with chromedriver, it's my fail.

Updated title to reflect the remaining task. The chromedriver patch has still not been merged, but when it is and a new rev is published we'll get on the android-driver changes.

@mayureshshirodkar @danqa @jlipps
Guys, can anybody help me, I'm going mad with this issue.
I can view in my logs

info: [debug] Getting a list of available webviews
info: [debug] executing cmd: C:Users\Raviraj\AppData\Local\Android\sdk\platform-toolsadb.exe -s 0915f9e3a0d20a05 shell "cat /proc/net/unix"
info: [debug] Available contexts: NATIVE_APP,CHROMIUM

How can i get my actual webview name instead of chromium

I have changed hybrid.js file below

androidHybrid.listWebviews = function (cb) {
  logger.debug("Getting a list of available webviews");
  var webviews = [];
  var definedDeviceSocket = this.args.androidDeviceSocket;
  this.adb.shell("cat /proc/net/unix", function (err, out) {
    if (err) return cb(err);
    _.each(out.split("\n"), function (line) {
      line = line.trim();
      var webviewPid = line.match(/@?com.bidchatapp.bidchat_devtools_remote_(\d+)/);
      if (definedDeviceSocket) {
        if (line.indexOf("@" + definedDeviceSocket) ===
          line.length - definedDeviceSocket.length - 1) {
          if (webviewPid) {
            webviews.push(this.WEBVIEW_BASE + webviewPid[1]);
          } else {
            webviews.push(this.CHROMIUM_WIN);
          }
        }
      } else if (webviewPid) {

Still i'm getting the same issue, can anybody please please help me

Latest logs mentioned below but still stuck with the error >> Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command. (Original error: Can't stop process; it's not currently running)","origValue":"Can't stop process; it's not currently running"},"sessionId":"a0f0de79-c67f-49bf-b142-f0a2e9291678"}

info: [debug] Available contexts: NATIVE_APP,WEBVIEW_undefined

info: [debug] Responding to client with success: {"status":0,"value":["NATIVE_APP","WEBVIEW_undefined"],"sessionId":"a0f0de79-c67f-49bf-b142-f0a2e9291678"}
info: <-- GET /wd/hub/session/a0f0de79-c67f-49bf-b142-f0a2e9291678/contexts 200 229.938 ms - 106 {"status":0,"value":["NATIVE_APP","WEBVIEW_undefined"],"sessionId":"a0f0de79-c67f-49bf-b142-f0a2e9291678"}
info: --> POST /wd/hub/session/a0f0de79-c67f-49bf-b142-f0a2e9291678/context {"name":"WEBVIEW_undefined"}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: C:Users\Raviraj\AppData\Local\Android\sdk\platform-toolsadb.exe -s 0915f9e3a0d20a05 shell "cat /proc/net/unix"
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_undefined
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_modulesappium\node_modulesappium-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_modulesappium\node_modulesappium-chromedriver\chromedriver\win\chromedriver.exe --url-base=wd/hub --port=9515
info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command. (Original error: Can't stop process; it's not currently running)","origValue":"Can't stop process; it's not currently running"},"sessionId":"a0f0de79-c67f-49bf-b142-f0a2e9291678"}
info: <-- POST /wd/hub/session/a0f0de79-c67f-49bf-b142-f0a2e9291678/context 500 377.649 ms - 280
info: [debug] Didn't get a new command in 60 secs, shutting down...
info: Shutting down appium session

Guys, I didn't do everything right, but it works good. The only issue I have - when I switch to webview(Chromium), Appium activates its ChromeDriver instead of some BaseDriver and my implicitlyWait stops working, when I switch back to the Native context, implicitlyWait begins working again.

  • It successfully works with elements as in native so in webview contexts.
    How can I set implicitlyWait command for the chromeDriver that I don't setup before tests? It setups automatically by appium when changing context to Chromium.

Appium version - 1.6.4-beta.2
Patched ChromeDriver by @ITKarel

public static AppiumDriver driver;

@Before
public void prepareAndroidForAppium() throws MalformedURLException, InterruptedException {

    DesiredCapabilities capabilities = new DesiredCapabilities();

    String ANDROID_APP_PACKAGE = "com.***.***";
    String ANDROID_DEVICE_SOCKET = ANDROID_APP_PACKAGE + "_devtools_remote";
    capabilities.setCapability("androidDeviceSocket", ANDROID_DEVICE_SOCKET);
    capabilities.setCapability("deviceName","Xperia Z3");
    capabilities.setCapability("platformVersion", "6.0.1");
    capabilities.setCapability("automationName", "uiautomator2");
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("appPackage", ANDROID_APP_PACKAGE);
    capabilities.setCapability("appActivity", ANDROID_APP_PACKAGE + ".MainActivity");
    capabilities.setCapability("chromedriverExecutable","C:\\Users\\qalit\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\appium-chromedriver\\chromedriver\\win\\chromedriver.exe");
    driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    driver.manage().timeouts().implicitlyWait(35, TimeUnit.SECONDS);
}

And these are appium console logs when appium launches ChromeDriver:

[debug] [AndroidDriver] Available contexts: ["NATIVE_APP","CHROMIUM"]
[debug] [AndroidDriver] Connecting to chrome-backed webview context 'CHROMIUM'
[debug] [AndroidDriver] A port was not given, using random port: 8000
[debug] [Chromedriver] Changed state to 'starting'
[Chromedriver] Set chromedriver binary as: C:\Users\qalit\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe
[Chromedriver] Killing any old chromedrivers, running: FOR /F "usebackq tokens=5" %a in (`netstat -nao ^| findstr /R /C:"8000 "`) do (FOR /F "usebackq" %b in (`TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe`) do (IF NOT %b=="" TASKKILL /F /PID %a))
[Chromedriver] No old chromedrivers seemed to exist
[Chromedriver] Spawning chromedriver with: C:\Users\qalit\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe --url-base=wd/hub --port=8000 --adb-port=5037
[Chromedriver] [STDOUT] Starting ChromeDriver 2.20.366854 (5ec7646c06c3266f27ae291db023e006190cc1cc) on port 8000
Only local connections are allowed.
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no body
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"10.0\"}}}"
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.litslink.lavo","androidUseRunningApp":true,"androidDeviceSerial":"CB5A20RVP2"}}}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"dc8406f7dde59731f69a54533907387c","status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.20.366854 (5ec7646c06c3266f27ae291db023e006190cc1cc)"},"cssSelectorsEnabled":true,"databaseEnabled":false,"handlesAlerts":true,"hasTouchScreen":true,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":false,"nativeEvents":true,"platform":"ANDROID","rotatable":false,"takesHeapSnapshot":true,"takesScreenshot":true,"version":"","webStorageEnabled":true}}
[debug] [Chromedriver] Changed state to 'online'

About ImplicitlyWait not working with 2 drivers in Appium. Just added driver Wait until... in click, check and input methods, the result is the same as with ImplicitlyWait. Looks like I got totally working appium in native+webview cordova app :D

public static void clickElement(By XPath, String ClickText) {
        WebDriverWait wait = new WebDriverWait(driver,30);
        wait.until(ExpectedConditions.visibilityOfElementLocated(XPath));
        driver.findElement(XPath).click();
        log.info(ClickText + " has been clicked");
    }

@Shakle does it work with multiple webviews? i.e. when app can open more than one webview? can you test it by any chance?

@letsrokk I can test it tomorrow, but I need some .apk where multiple webviews exist. Can you give me some link?

@Shakle I don't know any other example, except our app: <-- app link was here -->

You can create new user or use <-- username was here --> :) In app if you will navigate to Deposit options and try and initiate any payment through credit card it will open webview with payment form like that: <-- here was a screenshot -->

Edit: removed app link

@letsrokk
Will write in more details soon.
But I could easily work with that window in native view.
So I was in chromium all the time and just switched to native when card credentials have appeared - it works.

[NATIVE_APP, CHROMIUM]
2017-06-04 12:37:13 : login has been clicked
2017-06-04 12:37:15 : [email protected] has been written into input
2017-06-04 12:37:15 : 123456 has been written into input
submit
2017-06-04 12:37:24 : X has been clicked
2017-06-04 12:37:24 : first row has been clicked
2017-06-04 12:37:26 : buy has been clicked
2017-06-04 12:37:28 : buy 2 has been clicked
2017-06-04 12:37:28 : deposit has been clicked
2017-06-04 12:37:32 : bank has been clicked
2017-06-04 12:37:33 : deposit has been clicked
[NATIVE_APP, CHROMIUM]
2017-06-04 12:37:46 : helloworld has been written into cc

@Shakle yeah, native context works, no problem here, the problem was that I couldn't switch to that webview (my my patched Appium version).

Can you show driver.getContextHandles() result on card credentials screen? To see if it picks up all webviews.

Thanks in advance!

Edit: never mind, I'm blind :) I can see that only one webview is available - CHROMIUM - but that's good news that Appium 1.6.4-beta is working with Crosswalk apps (with patched chromedriver)

@letsrokk

Ok then :) The main thing that I see is that we can automate everything without any problem now.

I haven't been able to get the various solutions listed in this thread to work with Appium 1.6. My team also has some particular requirements that mean I needed a turnkey solution.

So if anyone else is having issues then you can try installing a modified version of Appium 1.6.3 by running:

npm install https://github.com/blutter/appium-crosswalk-fix/archive/v1.6.3.tar.gz
node_modules\appium-with-crosswalk-fix\node_modules\.bin\appium --chromedriver-executable=%cd%\node_modules\appium-with-crosswalk-fix\chromedriver\2.28\chromedriver.exe

So far it only has a patched version of Chromedriver for Windows.

Hey @luedeke ,

Quick question to get confirmation around this, when you do this driver.getContextHandles(), are you getting only one webview "CHROMIUM" with new appium version 1.6.4?

As I remember before we also use to get "WEBVIEW" isn't

Closing this issue, as we can find webviews from appium with a patched chromedriver.

@rkavalap Could you elaborate what you mean with

as we can find webviews from appium

Do you maybe have a link to the Appium documentation regarding updated webview-helpers that work with crosswalk? We can't seem to find it!

@MarsupiL I don't think appium itself has its docs updated with complete details.
This below PR fixes what's required from appium side with my patched chromedriver link above.
https://github.com/appium/appium-android-driver/pull/238

Hi guys , any news ? is there a way to automate crosswalk apks with Appium desktop ?

Hi all,

To help whoever might be stuck with this, two things:

  • It is not an Appium issue
  • Root cause is that WebViews require to be called with the “webview_devtools_remote_” prefix. Otherwise ChromeDriver does not recognise them. The CrossWalk framework calls them “appPackage_devtools_remote”, whatever appPackage your app is using.

Main recommendation, move away from CrossWalk since the project is closed and it is unlikely that ChromeDriver will do something to support a closed project which is not developed anymore.

If you need time to move away from CrossWalk and still automate the app, a solution is to recompile ChromeDriver. This is what we had to do:

Current patch that worked for us (in case someone is in the same situation):

diff --git a/chrome/test/chromedriver/chrome/device_manager.cc b/chrome/test/chromedriver/chrome/device_manager.cc
index 2558656d74..d8713d9859 100644
--- a/chrome/test/chromedriver/chrome/device_manager.cc
+++ b/chrome/test/chromedriver/chrome/device_manager.cc
@@ -159,10 +159,20 @@ Status Device::ForwardDevtoolsPort(const std::string& package,
     status = adb_->GetSocketByPattern(serial_, pattern, &socket_name);
     if (status.IsError()) {
       if (socket_name.empty())
+        LOG(WARNING) << "Webview with requited pattern webview_devtools_remote_ not found.";
+    }
+    LOG(WARNING) << "Will try to find a CrossWalk webview...";
+    std::string crosswalk_pattern =
+        base::StringPrintf("@%s_devtools_remote", package.c_str());
+    status = adb_->GetSocketByPattern(serial_, crosswalk_pattern, &socket_name);
+    if (status.IsError()) {
+      if (socket_name.empty()) {
         status.AddDetails(
             "make sure the app has its WebView configured for debugging");
+      }
       return status;
     }
+
     // When used in adb with "localabstract:", the leading '@' is not needed.
     *device_socket = socket_name.substr(1);
   }
diff --git a/chrome/test/chromedriver/chrome/navigation_tracker.cc b/chrome/test/chromedriver/chrome/navigation_tracker.cc
index b4c5b00ad3..7ba1ce3aa2 100644
--- a/chrome/test/chromedriver/chrome/navigation_tracker.cc
+++ b/chrome/test/chromedriver/chrome/navigation_tracker.cc
@@ -320,10 +320,10 @@ Status NavigationTracker::OnEvent(DevToolsClient* client,
     if (!params.GetInteger("context.id", &execution_context_id))
       return Status(kUnknownError, "missing or invalid 'context.id'");
     std::string frame_id;
-    if (!params.GetString("context.auxData.frameId", &frame_id)) {
-      return Status(kUnknownError,
-                    "missing or invalid 'context.auxData.frameId'");
-    }
+//    if (!params.GetString("context.auxData.frameId", &frame_id)) {
+//      return Status(kUnknownError,
+//                    "missing or invalid 'context.auxData.frameId'");
+//    }
     if (frame_id == dummy_frame_id_)
       dummy_execution_context_id_ = execution_context_id;
     else

and a Dockerfile to recompile ChromeDriver based on that patch, a binary for Linux is generated but the same principle can be followed for OSX and Windows

FROM ubuntu:16.04

# Install Chromium build dependencies.
RUN echo "deb http://archive.ubuntu.com/ubuntu trusty multiverse" >> /etc/apt/sources.list # && dpkg --add-architecture i386
RUN apt-get update && apt-get install -qy git build-essential clang curl lsb-release sudo

# Install Chromium's depot_tools.
ENV DEPOT_TOOLS /usr/bin/depot_tools
RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $DEPOT_TOOLS
ENV PATH $PATH:$DEPOT_TOOLS
RUN echo -e "\n# Add Chromium's depot_tools to the PATH." >> .bashrc
RUN echo "export PATH=\"\$PATH:$DEPOT_TOOLS\"" >> .bashrc

RUN git config --global https.postBuffer 1048576000

# Download Chromium sources.
RUN fetch --nohooks --no-history chromium

WORKDIR /

RUN gclient runhooks

WORKDIR src

RUN build/install-build-deps.sh --no-prompt

COPY crosswalk.patch crosswalk.patch
RUN git apply crosswalk.patch

RUN gn gen out/Release --args="is_debug=false"
RUN ninja -C out/Release chromedriver

RUN cp out/Release/chromedriver /usr/bin/chromedriver
RUN /usr/bin/chromedriver --version

WORKDIR /

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings