Skip to content

Switching back to webview - An unknown server-side error occurred - Original error: Unexpected token c in JSON at position 247 #259

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
amitrparmar opened this issue May 22, 2018 · 8 comments

Comments

@amitrparmar
Copy link

Description

I am getting an issue on iOS device when I switched to NATIVE view and try to back into Webview.

Environment

  • Appium server version: 1.8.0
  • MAC OS (Where appium runs): High Sierra 10.13.4
  • Desktop OS version: Windows 10
  • Mobile platform version: 10.3.3
  • Real device : iPAD 4

Details

AppiumDriver().getContextHandles();

APPIUM LOGs:

[HTTP] <-- GET /wd/hub/session/2b68dc2a-59d8-4925-bdd7-89d0ff51e90d/screenshot 200 2068 ms - 2024946
[HTTP]
[HTTP] --> GET /wd/hub/session/2b68dc2a-59d8-4925-bdd7-89d0ff51e90d/context
[HTTP] {}
[debug] [MJSONWP] Calling AppiumDriver.getCurrentContext() with args: ["2b68dc2a-59d8-4925-bdd7-89d0ff51e90d"]
[debug] [XCUITest] Executing command 'getCurrentContext'
[debug] [MJSONWP] Responding to client with driver.getCurrentContext() result: "NATIVE_APP"
[HTTP] <-- GET /wd/hub/session/2b68dc2a-59d8-4925-bdd7-89d0ff51e90d/context 200 2 ms - 84
[HTTP]
[HTTP] --> GET /wd/hub/session/2b68dc2a-59d8-4925-bdd7-89d0ff51e90d/contexts
[HTTP] {}
[debug] [MJSONWP] Calling AppiumDriver.getContexts() with args: ["2b68dc2a-59d8-4925-bdd7-89d0ff51e90d"]
[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
[MJSONWP] Encountered internal error running command: SyntaxError: Unexpected token c in JSON at position 247
[MJSONWP] at JSON.parse ()
[MJSONWP] at WebKitRemoteDebugger.getJsonFromUrl$ (/usr/local/lib/node_modules/appium/node_modules/appium-remote-debugger/lib/webkit-remote-debugger.js:85:22)
[MJSONWP] at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[MJSONWP] at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
[MJSONWP] at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
[MJSONWP] at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[MJSONWP] at
[HTTP] <-- GET /wd/hub/session/2b68dc2a-59d8-4925-bdd7-89d0ff51e90d/contexts 500 7 ms - 213

Java Client Error

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Unexpected token c in JSON at position 247 (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 16 milliseconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'COMPUTER000117', ip: '192.168.133.60', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91'
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities [{app=/Users/admin/Desktop/IPA/TouchClassic_5.0.1.app, networkConnectionEnabled=false, databaseEnabled=false, deviceName=ipad, fullReset=true, platform=MAC, showXcodeLog=true, newCommandTimeout=300, platformVersion=10.3.1, webStorageEnabled=false, locationContextEnabled=false, automationName=XCUITest, browserName=, takesScreenshot=true, javascriptEnabled=true, platformName=iOS, udid=d8a8f24c27769d00627929f291b15eb015e9e8c4, autoAcceptAlerts=true}]
Session ID: 2b68dc2a-59d8-4925-bdd7-89d0ff51e90d

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:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:235)
at io.appium.java_client.AppiumDriver.getContextHandles(AppiumDriver.java:562)

Requesting JSON url

I'm getting below JSON while hitting http://localhost:27753/json URL.

[{
  "devtoolsFrontendUrl": "/devtools/devtools.html?ws=192.168.134.46:27753/devtools/page/8",
  "faviconUrl": "",
  "thumbnailUrl": "/thumb/http://192.168.134.212/touchcg/?device=ios&sftouch=1&secure=1#pages/callscalendar/{"loadTime"%3A"3322"}",
  "title": "Consumer Goods 12.20",
  "url": "http://192.168.134.212/touchcg/?device=ios&sftouch=1&secure=1#pages/callscalendar/{"loadTime"%3A"3322"}",
  "webSocketDebuggerUrl": "ws://192.168.134.46:27753/devtools/page/8",
  "appId": "PID:322"
}]

Error

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Unexpected token l in JSON at position 223 (WARNING: The server did not provide any stacktrace information)

@jacattau
Copy link

I'm getting similar behavior but not the same error. iOS 11.3, Appium 1.8.1, IWDP 1.8. I can't get into a webview at all.

[debug] [W3C] Calling AppiumDriver.getContexts() with args: ["cefcc8fd-3629-4640-986e-59757a20de62"] [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/A7581B35-D48A-4086-A175-A2615C83E41E/Quotes.app/www/index.html","title":"Quotes for Sales Professionals","url":"http://localhost:8080/var/containers/Bundle/Application/A7581B35-D48A-4086-A175-A2615C83E41E/Quotes.app/www/index.html","webSocketDebuggerUrl":"ws://localhost:27753/devtools/page/2","appId":"PID:428"}] [debug] [MJSONWP] Responding to client with driver.getContexts() result: ["NATIVE_APP","WEBVIEW_2"] [HTTP] <-- GET /wd/hub/session/cefcc8fd-3629-4640-986e-59757a20de62/contexts 200 8 ms - 98 [HTTP] [HTTP] --> POST /wd/hub/session/cefcc8fd-3629-4640-986e-59757a20de62/context [HTTP] {"name":"WEBVIEW_2"} [debug] [W3C] Calling AppiumDriver.setContext() with args: ["WEBVIEW_2","cefcc8fd-3629-4640-986e-59757a20de62"] [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. [debug] [XCUITest] Connection to WDA timed out [debug] [iProxy] recv failed: Operation not permitted [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/cefcc8fd-3629-4640-986e-59757a20de62/context 500 5014 ms - 190

@artygus artygus reopened this May 23, 2018
@artygus
Copy link
Collaborator

artygus commented May 23, 2018

please checkout master branch

brew reinstall --HEAD ios-webkit-debug-proxy

@mailsumit86
Copy link

brew reinstall --HEAD ios-webkit-debug-proxy doesn't work. I also tried updating Appium to latest version 1.8.1, but no success.

@artygus
Copy link
Collaborator

artygus commented Jun 11, 2018

hi @mailsumit86, can you confirm you're seeing same issue the OP posted above?

[MJSONWP] Encountered internal error running command: SyntaxError: Unexpected token c in JSON at position ...

@mailsumit86
Copy link

Below is the log trace from appium :

[Appium] Capabilities:
[Appium] webkitResponseTimeout: 120000
[Appium] preventWDAAttachments: true
[Appium] noReset: false
[Appium] startIWDP: true
[Appium] newCommandTimeout: 500
[Appium] platformVersion: 11.1
[Appium] automationName: XCUITest
[Appium] browserName: safari
[Appium] --session-override: true
[Appium] platformName: iOS
[Appium] udid: 6f30a0c6f5a8eb2b7a490145ba110f721be8f1cc
[Appium] deviceName: iPhone8
[BaseDriver] The following capabilities were provided, but are not recognized by appium: --session-override.
[BaseDriver] Session created with session id: 72ce88d1-effa-432c-9d1e-05668bbe913c
[XCUITest] Determining device to run tests on: udid: '6f30a0c6f5a8eb2b7a490145ba110f721be8f1cc', real device: true
[XCUITest] Safari test requested
[XCUITest] Setting up real device
[XCUITest] Using WDA path: '/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent'
[XCUITest] Using WDA agent: '/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj'
[XCUITest] Will reuse previously cached WDA instance at 'http://localhost:8100/'. Set the wdaLocalPort capability to a value different from 8100 if this is an undesired behavior.
[XCUITest] Using provided WebdriverAgent at 'http://localhost:8100/'
[XCUITest] Setting '555' permissions to '/Users/cnbcqa/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Logs/Test/Attachments' folder
[XCUITest] Skipping setting of the initial display orientation. Set the "orientation" capability to either "LANDSCAPE" or "PORTRAIT", if this is an undesired behavior.
[XCUITest] TimeoutError: operation timed out
[XCUITest] at afterTimeout (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/release/timers.js:46:19)
[XCUITest] at Timeout.timeoutTimeout [as _onTimeout] (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/release/timers.js:76:13)
[XCUITest] at ontimeout (timers.js:458:11)
[XCUITest] at tryOnTimeout (timers.js:296:5)
[XCUITest] at Timer.listOnTimeout (timers.js:259:5)
[XCUITest] Setting '755' permissions to '/Users/cnbcqa/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Logs/Test/Attachments' folder
[MJSONWP] Encountered internal error running command: TimeoutError: operation timed out
[MJSONWP] at afterTimeout (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/release/timers.js:46:19)
[MJSONWP] at Timeout.timeoutTimeout [as _onTimeout] (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/release/timers.js:76:13)
[MJSONWP] at ontimeout (timers.js:458:11)
[MJSONWP] at tryOnTimeout (timers.js:296:5)
[MJSONWP] at Timer.listOnTimeout (timers.js:259:5)
[HTTP] <-- POST /wd/hub/session 500 125623 ms - 156

The safari opens up and go to appium.io, but then just crashes.

@artygus
Copy link
Collaborator

artygus commented Jun 11, 2018

are you using appium 1.8.1? there was a bug #258 (comment) appium/appium#10741

@artygus
Copy link
Collaborator

artygus commented Jun 11, 2018

from the log I can't see any erroneous output from IWDP, anyways it doesn't seem to be related to original issue, feel free to open a new issue providing more details on the issue, it could be related to appium eco-system

@artygus
Copy link
Collaborator

artygus commented Jun 11, 2018

closing the issue since JSON parsing part was fixed in 2f08a1c.

@artygus artygus closed this as completed Jun 11, 2018
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