Skip to content

IWDP Struggles to detect webview, however, when it does, operation after switching to webview times out. (iOS 11.2.1, xcode 9.3) #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kdthomas2121 opened this issue May 8, 2018 · 26 comments

Comments

@kdthomas2121
Copy link

I've been struggling for a few days to get IWDP to view a webview on a hybrid app. But I've been able to do it semi-reliably now. However, after switching to the webview, any action I try and perform results in:
Selenium::WebDriver::Error::UnknownError: An unknown server-side error occurred while processing the command. Original error: operation timed out
from UnknownError: An unknown server-side error occurred while processing the command. Original error: operation timed out.

Here's the log from IWDP immediately after trying to find a CSS selector

00 00 DD 5D 62 70 6C 69 73 74 30 30 D2 01 03 02 04 5A 5F ...]bplist00.....Z_ 5F 73 65 6C 65 63 74 6F 72 5F 10 17 5F 72 70 63 5F 66 6F _selector_.._rpc_fo 72 77 61 72 64 53 6F 63 6B 65 74 44 61 74 61 3A 5A 5F 5F rwardSocketData:Z__ 61 72 67 75 6D 65 6E 74 D5 05 07 09 0B 0D 06 08 0A argument......... 0C 0E 5F 10 1A 57 49 52 43 6F 6E 6E 65 63 74 69 6F 6E 49 .._..WIRConnectionI 64 65 6E 74 69 66 69 65 72 4B 65 79 5F 10 24 31 34 37 35 dentifierKey_.$1475 33 41 39 45 2D 37 31 42 43 2D 34 32 41 42 2D 38 30 37 43 3A9E-71BC-42AB-807C 2D 33 32 46 35 43 33 45 37 38 31 30 34 5F 10 1B 57 49 52 -32F5C3E78104_..WIR 41 70 70 6C 69 63 61 74 69 6F 6E 49 64 65 6E 74 69 66 69 ApplicationIdentifi 65 72 4B 65 79 57 50 49 44 3A 34 36 39 5F 10 14 57 49 52 erKeyWPID:469_..WIR 50 61 67 65 49 64 65 6E 74 69 66 69 65 72 4B 65 79 10 01 PageIdentifierKey.. 5C 57 49 52 53 65 6E 64 65 72 4B 65 79 5F 10 24 34 32 44 \WIRSenderKey_.$42D 44 30 37 41 45 2D 31 45 34 36 2D 34 45 34 35 2D 41 30 43 D07AE-1E46-4E45-A0C 41 2D 33 44 33 39 30 46 35 39 36 42 36 32 5F 10 10 57 49 A-3D390F596B62_..WI 52 53 6F 63 6B 65 74 44 61 74 61 4B 65 79 4F 11 DC 09 7B RSocketDataKeyO...{ 22 6D 65 74 68 6F 64 22 3A 22 52 75 6E 74 69 6D 65 2E 65 "method":"Runtime.e 76 61 6C 75 61 74 65 22 2C 22 70 61 72 61 6D 73 22 3A 7B valuate","params":{ 22 6F 62 6A 65 63 74 47 72 6F 75 70 22 3A 22 63 6F 6E 73 "objectGroup":"cons 6F 6C 65 22 2C 22 69 6E 63 6C 75 64 65 43 6F 6D 6D 61 6E ole","includeComman 64 4C 69 6E 65 41 50 49 22 3A 74 72 75 65 2C 22 64 6F 4E dLineAPI":true,"doN 6F 74 50 61 75 73 65 4F 6E 45 78 63 65 70 74 69 6F 6E 73 otPauseOnExceptions 41 6E 64 4D 75 74 65 43 6F 6E 73 6F 6C 65 22 3A 74 72 75 AndMuteConsole":tru 65 2C 22 65 78 70 72 65 73 73 69 6F 6E 22 3A 22 28 66 75 e,"expression":"(fu 6E 63 74 69 6F 6E 28 29 7B 72 65 74 75 72 6E 20 66 75 6E nction(){return fun 63 74 69 6F 6E 28 29 7B 76 61 72 20 6B 3D 74 68 69 73 3B ction(){var k=this; 66 75 6E 63 74 69 6F 6E 20 6C 28 61 29 7B 72 65 74 75 72 function l(a){retur 6E 20 76 6F 69 64 20 30 21 3D 3D 61 7D 66 75 6E 63 74 69 n void 0!==a}functi 6F 6E 20 71 28 61 29 7B 72 65 74 75 72 6E 5C 22 73 74 72 on q(a){return\"str 69 6E 67 5C 22 3D 3D 74 79 70 65 6F 66 20 61 7D 66 75 6E ing\"==typeof a}fun 63 74 69 6F 6E 20 61 61 28 61 2C 62 29 7B 61 3D 61 2E 73 ction aa(a,b){a=a.s 70 6C 69 74 28 5C 22 2E 5C 22 29 3B 76 61 72 20 63 3D 6B plit(\".\");var c=k +56086 ss.sendq<0x7ff3a9c04d90> new fd=7 recv_fd=5 length=48481, prev=<0x0> ss.sendq<0x7ff3a9c04d90> disable recv_fd=5 ss.sendq<0x7ff3a9c04d90> resume send to fd=7 len=48481 ss.sendq<0x7ff3a9c04d90> defer len=40289 ss.sendq<0x7ff3a9c04d90> resume send to fd=7 len=40289 ss.sendq<0x7ff3a9c04d90> defer len=32097 ss.sendq<0x7ff3a9c04d90> resume send to fd=7 len=32097 ss.sendq<0x7ff3a9c04d90> defer len=23905 ss.sendq<0x7ff3a9c04d90> resume send to fd=7 len=23905 ss.sendq<0x7ff3a9c04d90> defer len=15713 ss.sendq<0x7ff3a9c04d90> resume send to fd=7 len=15713 ss.sendq<0x7ff3a9c04d90> defer len=7521 ss.sendq<0x7ff3a9c04d90> resume send to fd=7 len=7521 ss.sendq<0x7ff3a9c04d90> re-enable recv_fd=5 ss.sendq<0x7ff3a9c04d90> free, next=<0x0>

And here is the appium log [debug] [RemoteDebugger] Executing 'find_element' atom in default context [debug] [RemoteDebugger] Sending javascript command (function(){return function(){var k=this;functi... [debug] [RemoteDebugger] Sending WebKit data: {"method":"Runtime.evaluate","params":{"objectGroup":"console","includeCommandLineAPI":true,"doNotPauseOnExceptionsAndMuteConsole":true,"expression":"(function(){return function(){var k=this;functi... [debug] [RemoteDebugger] Webkit response timeout: 2000 (node:2917) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): TimeoutError: operation timed out [W3C] Encountered internal error running command: TimeoutError: operation timed out [W3C] at afterTimeout (/usr/local/lib/node_modules/appium/node_modules/appium-remote-debugger/node_modules/bluebird/js/release/timers.js:46:19) [W3C] at Timeout.timeoutTimeout [as _onTimeout] (/usr/local/lib/node_modules/appium/node_modules/appium-remote-debugger/node_modules/bluebird/js/release/timers.js:76:13) [W3C] at ontimeout (timers.js:386:11) [W3C] at tryOnTimeout (timers.js:250:5) [W3C] at Timer.listOnTimeout (timers.js:214:5) [HTTP] <-- POST /wd/hub/session/da4e2d55-3db6-4fbf-aa41-f0cb684c8efd/element 500 2039 ms - 1102 [HTTP] [HTTP] --> POST /wd/hub/session/da4e2d55-3db6-4fbf-aa41-f0cb684c8efd/element [HTTP] {"using":"css selector","value":"#account-bar-login-btn"}

The commands are being sent as fast as possible, so unsure why it's timing out. If I can help with anymore info, let me know!

@artygus
Copy link
Collaborator

artygus commented May 8, 2018

I can't see any errors in messages from iwdp, are you certain the issue is not related to appium?

@artygus
Copy link
Collaborator

artygus commented May 8, 2018

if you can craft a minimal example app and provide appium script it would certainly help

@kdthomas2121
Copy link
Author

I'm not a developer I'm afraid so don't have the know-how to do so. I've also tried viewing the inspectable applications via http://localhost:27743/ (custom port) but the hybrid app doesn't appear. Is there a way I can determine if it is appium or IWDP?

@artygus
Copy link
Collaborator

artygus commented May 8, 2018

You can run ios_webkit_debug_proxy in terminal, navigate to http://localhost:9221 to see devices, but it won't give you much information. Also you could send messages via websocket directly to iwdp, but I think it's gonna be tough (depending on complexity of your appium script).

Could you please provide a gist of appium script? It would give at least some information

@kdthomas2121
Copy link
Author

kdthomas2121 commented May 8, 2018

Sure, my capabilities are:

local_capabilities= { caps: { platformName: 'iOS', platformVersion: '11.2.1', udid: 'auto', deviceName: "IWC iPad Mini", autoWebview: false, startIWDP: false, locationServicesEnabled: true, locationServicesAuthorized: true, processArguments: create_processArgs(opts), xcodeSigningId: 'iPhone Developer', showXcodeLog: true, usePrebuiltWDA: true, #ensure to build WebDriverRunner on device webkitResponseTimeout: '2000', webkitDebugProxyPort: '27743', shutdownOtherSimulators: true,

The only bit of the appium script I'm trying to run at present is

`available_views = @dom_interaction.driver.available_contexts

@dom_interaction.driver.set_context(available_views[1])
puts "available contexts ==== " + available_views.inspect

els5 = @dom_interaction.driver.find_element(:css, "#account-bar-login-btn")
els5.click`

@artygus
Copy link
Collaborator

artygus commented May 8, 2018

startIWDP is set to false, are you testing on emulator device?

UPD: Oh sorry, I see you're testing on real device, this config line is a bit confusing

@kdthomas2121
Copy link
Author

kdthomas2121 commented May 8, 2018 via email

@kdthomas2121
Copy link
Author

It now won't find the webview anymore, it looks like it's closing the connection for some reason?

ss.accept server=4 new_client=5 ss.add_fd(5) ss.recv fd=5 len=64 ws.recv[64]: 47 45 54 20 2F 6A 73 6F 6E 20 48 54 54 50 2F 31 2E 31 0D GET /json HTTP/1.1. 0A . 68 6F 73 74 3A 20 6C 6F 63 61 6C 68 6F 73 74 3A 32 37 37 host: localhost:277 34 33 0D 0A 43.. 43 6F 6E 6E 65 63 74 69 6F 6E 3A 20 63 6C 6F 73 65 0D 0A Connection: close.. 0D 0A .. ss.remove_fd(5)

@artygus
Copy link
Collaborator

artygus commented May 8, 2018

Connection: close is a normal header, meaning keep alive is not supported

@artygus
Copy link
Collaborator

artygus commented May 8, 2018

What's your app mechanics in terms of dynamic webviews? I'm not sure what "struggles" in the title means? If you run your app with only iwdp running (no appium) can you see all the webviews?

@kdthomas2121
Copy link
Author

So WEBVIEW_1 should always be an available context. And by struggles, sometimes I can view the webview, sometimes I can't, running the exact same set up. I've been trying to reproduce what could cause me to see the webview reliably, but I can't, currently can't see the webview via appium or http://localhost:27743/

@artygus
Copy link
Collaborator

artygus commented May 8, 2018

can you see it in safari under develop tab?

@kdthomas2121
Copy link
Author

No I can't

@artygus
Copy link
Collaborator

artygus commented May 8, 2018

it's unlikely iwdp can detect webview if safari failed to do so (unless you have older version of safari,
in this case you won't be able to detect any webviews from your current device), probably webinspectord hanged or something

@kdthomas2121
Copy link
Author

Hmm, I have been able to see the webview via IWDP/Appium though, and never actually been able to see it in Safari (I have the latest version)

@artygus
Copy link
Collaborator

artygus commented May 8, 2018

that's interesting, what if you install safari technology preview?

@kdthomas2121
Copy link
Author

No, still not present in the the tech preview

@kdthomas2121
Copy link
Author

@artygus do you have any ideas? Can't see any inspectable hybrid applications in IWDP or Safari inspector, can see safari pages though on 11.2.1. However, sometimes it will just appear and I can't figure out how

@artygus
Copy link
Collaborator

artygus commented May 17, 2018

@kdthomas2121 maybe it's related to the app mechanics? are webviews dynamic (appear on user interaction)?

@kdthomas2121
Copy link
Author

kdthomas2121 commented May 18, 2018 via email

@jacattau
Copy link

Experiencing almost the same issue essentially after upgrading to Appium 1.8.1. It can see the webview but when it tried to switch to it, it just says it times out even though it fails after about 2 seconds.

[debug] [MJSONWP] Responding to client with driver.getContexts() result: ["NATIVE_APP","WEBVIEW_2"] [HTTP] <-- GET /wd/hub/session/f5dd25d9-f51c-4567-bccd-37499520f644/contexts 200 7 ms - 98 [HTTP] [HTTP] --> GET /wd/hub/session/f5dd25d9-f51c-4567-bccd-37499520f644/contexts [HTTP] {} [debug] [W3C] Calling AppiumDriver.getContexts() with args: ["f5dd25d9-f51c-4567-bccd-37499520f644"] [debug] [XCUITest] Executing command 'getContexts' [debug] [iOS] Getting list of available contexts [debug] [iOS] Retrieving contexts and views [debug] [iOS] Selecting by url: false [debug] [RemoteDebugger] Getting WebKitRemoteDebugger pageArray: localhost, 27753 [debug] [RemoteDebugger] Sending request to: http://localhost:27753/json [debug] [RemoteDebugger] Page element JSON: [{"devtoolsFrontendUrl":"/devtools/devtools.html?ws=localhost:27753/devtools/page/2","faviconUrl":"","thumbnailUrl":"/thumb/http://localhost:8080/var/containers/Bundle/Application/D9F90292-42AB-42F5-A89A-C103421658FB/Quotes.app/www/index.html","title":"Quotes for Sales Professionals","url":"http://localhost:8080/var/containers/Bundle/Application/D9F90292-42AB-42F5-A89A-C103421658FB/Quotes.app/www/index.html","webSocketDebuggerUrl":"ws://localhost:27753/devtools/page/2","appId":"PID:401"}] [debug] [MJSONWP] Responding to client with driver.getContexts() result: ["NATIVE_APP","WEBVIEW_2"] [HTTP] <-- GET /wd/hub/session/f5dd25d9-f51c-4567-bccd-37499520f644/contexts 200 6 ms - 98 [HTTP] [HTTP] --> POST /wd/hub/session/f5dd25d9-f51c-4567-bccd-37499520f644/context [HTTP] {"name":"WEBVIEW_2"} [debug] [W3C] Calling AppiumDriver.setContext() with args: ["WEBVIEW_2","f5dd25d9-f51c-4567-bccd-37499520f644"] [debug] [XCUITest] Executing command 'setContext' [debug] [iOS] Attempting to set context to 'WEBVIEW_2' [debug] [RemoteDebugger] WebKit debugger web socket connected to url: ws://localhost:27753/devtools/page/2 [debug] [RemoteDebugger] Starting to listen for JavaScript console [debug] [RemoteDebugger] Sending WebKit data: {"method":"Console.enable","params":{"objectGroup":"console","includeCommandLineAPI":true,"doNotPauseOnExceptionsAndMuteConsole":true}} [debug] [RemoteDebugger] Webkit response timeout: 5000 [debug] [RemoteDebugger] Receiving WebKit data: '{"result":{},"id":1}' [debug] [RemoteDebugger] Found handler for message '1' [debug] [RemoteDebugger] WebKit debugger got a message for 'Console.enable' and have no handler, doing nothing. [MJSONWP] Encountered internal error running command: TimeoutError: operation timed out [MJSONWP] at afterTimeout (/Users/req90562/npm/lib/node_modules/appium/node_modules/bluebird/js/release/timers.js:46:19) [MJSONWP] at Timeout.timeoutTimeout [as _onTimeout] (/Users/req90562/npm/lib/node_modules/appium/node_modules/bluebird/js/release/timers.js:76:13) [MJSONWP] at ontimeout (timers.js:460:11) [MJSONWP] at tryOnTimeout (timers.js:298:5) [MJSONWP] at Timer.listOnTimeout (timers.js:261:5) [HTTP] <-- POST /wd/hub/session/f5dd25d9-f51c-4567-bccd-37499520f644/context 500 5009 ms - 190

@jacattau
Copy link

artygus posted on google/ios-webkit-debug-proxy#259 to perform brew reinstall --HEAD ios-webkit-debug-proxy. I can now see my device listed when running ios_webkit_debug_proxy but Appium 1.8.1 still errors out when trying to switch to it. FWIW, Appium 1.8.0 does not have this issue and I can switch to the webview no problem.

@artygus
Copy link
Collaborator

artygus commented May 30, 2018

@kdthomas2121 if testobjects.com works fine, the issue could be related to your local environment. did you try to redo pairing? e.g. by cleaning /var/db/lockdown/<hash>.plist

@artygus
Copy link
Collaborator

artygus commented Jun 11, 2018

issue seem to be related to regression introduced in appium 1.8.1 appium/appium#10741

@artygus artygus closed this as completed Jun 11, 2018
@kdthomas2121
Copy link
Author

Still not working for me after updating to the new appium beta as detailed in that issue! Let me know if I can provide anymore info

@drzajwo
Copy link

drzajwo commented Jun 14, 2018

@kdthomas2121 for me after updating to 1.8.2-beta new problem occured - described here Issue 924

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants