I wan't able to run a JavaScript executor command with the latest Java Client 6.00 beta5 which worked fine with Java Client 5.0.1.
The java script command used taps an element on a hybrid application. On executing the command Appium hangs on Android, but the same command works fine with iOS device.
Here are the Appium logs for the error with Java Client 6.0.0 Beta 5:
[HTTP] --> POST /wd/hub/session/2ebfe2fc-538e-4a33-b84b-8d023a2d27bd/execute/sync
[HTTP] {"script":"const TAP= new Event('tap', {bubbles: true}); arguments[0].dispatchEvent(TAP);","args":[{"ELEMENT":"0.9278807728181824-1","element-6066-11e4-a52e-4f735466cecf":"0.9278807728181824-1"}]}
[W3C] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/2ebfe2fc-538e-4a33-b84b-8d023a2d27bd/execute/sync] to [POST http://127.0.0.1:8000/wd/hub/session/8dc1232c77493a0c5b7323d5a03c990a/execute/sync] with body: {"script":"const TAP= new Event('tap', {bubbles: true}); arguments[0].dispatchEvent(TAP);","args":[{"ELEMENT":"0.9278807728181824-1","element-6066-11e4-a52e-4f735466cecf":"0.9278807728181824-1"}]}
[JSONWP Proxy] Got unexpected response: unknown command: session/8dc1232c77493a0c5b7323d5a03c990a/execute/sync
Appium log working command with Java client 5.0.1:
[HTTP] --> POST /wd/hub/session/57374a80-d0df-41bc-829c-aa88b75643a5/execute
[HTTP] {"script":"const TAP= new Event('tap', {bubbles: true}); arguments[0].dispatchEvent(TAP);","args":[{"ELEMENT":"0.2145516341478002-1","element-6066-11e4-a52e-4f735466cecf":"0.2145516341478002-1"}]}
[W3C] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/57374a80-d0df-41bc-829c-aa88b75643a5/execute] to [POST http://127.0.0.1:8000/wd/hub/session/0a8fdc1898d6058a901662156269db80/execute] with body: {"script":"const TAP= new Event('tap', {bubbles: true}); arguments[0].dispatchEvent(TAP);","args":[{"ELEMENT":"0.2145516341478002-1","element-6066-11e4-a52e-4f735466cecf":"0.2145516341478002-1"}]}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"0a8fdc1898d6058a901662156269db80","status":0,"value":null}
[JSONWP Proxy] Replacing sessionId 0a8fdc1898d6058a901662156269db80 with 57374a80-d0df-41bc-829c-aa88b75643a5
[HTTP] <-- POST /wd/hub/session/57374a80-d0df-41bc-829c-aa88b75643a5/execute 200 606 ms - 76
JavascriptExecutor js = Setup.getInstance().getWebDriver();
js.executeScript("const TAP= new Event('tap', {bubbles: true}); arguments[0].dispatchEvent(TAP);", el);
Entire Log gist: https://gist.github.com/mayureshshirodkar/3f50762e04243fb4358f8cffd7b145d3
@mayureshshirodkar any reason for using javascript executor for tap action ? Instead of following standard practice per java-client/docs/Touch-actions.md
App doesn't listen to click actions(performing the click action has no effect on the intended button) but only Tap action hence using java script executor to perform a web tap.
Also i need a web tap and not a native tap
@SrinivasanTarget Anything that i could do different with this?
@mayureshshirodkar can you try with the latest java-client ... This looks like W3C issue. We don't do anything on the client side
Yes, this is definitely W3C issue. The outer driver works in W3C mode, but the inner one (chromedriver) still expects JSONWP, so appium should either properly translate this request into JSONWP mode (since the endpoint for executeScript is different in this mode) or should init chromedriver in W3C mode as well.
@dpgraham Can you please take a look?
@mykola-mokhnach Yep, I can take this. Chromedriver doesn't support W3C fully yet so we'll have to do JSONWP translations.
@dpgraham I have something to address it though:
https://github.com/appium/appium-base-driver/pull/238
@mykola-mokhnach @saikrishna321 is this issue fixed?
which java-client version will have this fix?
Yes this is fixed in appium@beta
Thanks @mykola-mokhnach. Works well with [email protected] with java-client commit dfb285e3b836f8b57bfec0d2e128bcae1deb4734