question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[XCUITest] SyntaxError: Unexpected token < in JSON at position 0'

See original GitHub issue

The problem

Seeing Unexpected token < in JSON at position 0’ after simulator is triggered.

Environment

  • Appium version (or git revision) that exhibits the issue: v1.6.0
  • Last Appium version that did not exhibit the issue (if applicable): v 1.5.3
  • Desktop OS/version used to run Appium: MAC OS X EI Capitan 10.11.6
  • Node.js version (unless using Appium.app|exe): v6.7.0
  • Mobile platform/version under test: IOS/10.0
  • Real device or emulator/simulator: Simulator
  • Appium CLI or Appium.app|exe: Appium.app

Details

On trying to run a test case, I am seeing this error ‘[XCUITest] SyntaxError: Unexpected token < in JSON at position 0’. Please take a look into the below log.

node . --app /Users/abc/Desktop/xxx.app
[Appium] Welcome to Appium v1.6.0
[Appium] Non-default server args:
[Appium] app: '/Users/abc/Desktop/xxx.app'
[Appium] Deprecated server args:
[Appium] --app => --default-capabilities '{"app":"/Users/abc/Desktop/xxx.app"}'
[Appium] Default capabilities, which will be added to each request unless overridden by desired capabilities:
[Appium] app: '/Users/abc/Desktop/xxx.app'
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"newCommandTimeout":360000,"platform":"MAC","platformVersion":"10.0","platformName":"iOS","deviceName":"iPhone 6","autoDismissAlerts":true}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"newCommandTimeout":36000...
[Appium] Requested iOS support with version >= 10, using XCUITest driver instead of UIAutomation-based driver, since the latter is unsupported on iOS 10 and up.
[Appium] Creating new XCUITestDriver session
[Appium] Capabilities:
[Appium] newCommandTimeout: 360000
[Appium] platform: 'MAC'
[Appium] platformVersion: '10.0'
[Appium] platformName: 'iOS'
[Appium] deviceName: 'iPhone 6'
[Appium] autoDismissAlerts: true
[Appium] app: '/Users/abc/Desktop/xxx.app'
[debug] [XCUITest] XCUITestDriver version: 2.0.25
[BaseDriver] The following capabilities were provided, but are not recognized by appium: platform.
[BaseDriver] Session created with session id: 458b8ebe-d810-42f0-806d-ca5b6edb5de5
[debug] [XCUITest] Xcode version set to '8.0'
[debug] [XCUITest] iOS SDK Version set to '10.0'
[iOSSim] Constructing iOS simulator for Xcode version 8.0 with udid 'E423110B-107C-482C-9BFC-38AC3A9D05A2'
[XCUITest] Determining device to run tests on: udid: 'E423110B-107C-482C-9BFC-38AC3A9D05A2', real device: false
[BaseDriver] Using local app '/Users/abc/Desktop/xxx.app'
[debug] [XCUITest] Checking whether app is actually present
[debug] [ios-app-utils] Getting bundle ID from app
[debug] [iOSLog] Starting iOS 10.0 simulator log capture
[debug] [iOSLog] System log path: /Users/abc/Library/Logs/CoreSimulator/E423110B-107C-482C-9BFC-38AC3A9D05A2/system.log
[XCUITest] Setting up simulator
[debug] [iOS] No reason to set locale
[debug] [iOS] No iOS / app preferences to set
[XCUITest] Simulator with udid 'E423110B-107C-482C-9BFC-38AC3A9D05A2' not booted. Booting up now
[debug] [iOSSim] Killing all iOS Simulators
[iOSSim] Starting simulator with command: open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID E423110B-107C-482C-9BFC-38AC3A9D05A2
[iOSSim] Tailing simulator logs until we encounter the string "SMS Plugin initialized"
[iOSSim] We will time out after 60000ms
[debug] [iOSSim] Waiting an extra 10000ms for the simulator to really finish booting
[debug] [iOSSim] Done waiting extra time for simulator
[iOSSim] Simulator booted in 13688ms
[debug] [XCUITest] Installing app '/Users/abc/Desktop/xxx.app' on device
[XCUITest] Using default agent: /Users/abc/Downloads/appium-1.6.0/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj
[XCUITest] Using default bootstrap: /Users/abc/Downloads/appium-1.6.0/node_modules/appium-xcuitest-driver/WebDriverAgent
[XCUITest] Launching WebDriverAgent on the device
[debug] [XCUITest] Carthage found: /usr/local/bin/carthage
[debug] [XCUITest] Beginning test with command 'xcodebuild build test -project /Users/abc/Downloads/appium-1.6.0/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=E423110B-107C-482C-9BFC-38AC3A9D05A2 -configuration Debug' in directory '/Users/abc/Downloads/appium-1.6.0/node_modules/appium-xcuitest-driver/WebDriverAgent'
[XCUITest] Waiting for WebDriverAgent to start on device
[debug] [XCUITest] Log file for xcodebuild test: /Users/abc/Library/Developer/Xcode/DerivedData/WebDriverAgent-dfdievcxyrzumfawcyrwmemylwmf/Logs/Test/9AEF6490-9D30-45CA-8E5B-05588B56018B/Session-WebDriverAgentRunner-2016-10-13_124248-GDoOSh.log
[debug] [WebDriverAgent] Sim: Oct 13 12:42:50 CoreSimulatorBridge[37846]: Requesting installation of file:///Users/abc/Library/Developer/Xcode/DerivedData/WebDriverAgent-dfdievcxyrzumfawcyrwmemylwmf/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app/ with options: {
[debug] [WebDriverAgent] Sim: CFBundleIdentifier = "com.apple.test.WebDriverAgentRunner-Runner";
[debug] [WebDriverAgent] Sim: PackageType = Developer;
[debug] [WebDriverAgent] Sim: SimulatorRootPath = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk";
[debug] [WebDriverAgent] Sim: SimulatorUserPath = "/Users/abc/Library/Developer/CoreSimulator/Devices/E423110B-107C-482C-9BFC-38AC3A9D05A2/data";
[debug] [WebDriverAgent] Sim: }
[debug] [WebDriverAgent] Sim: Oct 13 12:42:53 CoreSimulatorBridge[37846]: Requesting launch of com.apple.test.WebDriverAgentRunner-Runner with options: {
[debug] [WebDriverAgent] Sim: arguments = (
[debug] [WebDriverAgent] Sim: "-NSTreatUnknownArgumentsAsOpen",
[debug] [WebDriverAgent] Sim: NO,
[debug] [WebDriverAgent] Sim: "-ApplePersistenceIgnoreState",
[debug] [WebDriverAgent] Sim: YES
[debug] [WebDriverAgent] Sim: );
[debug] [WebDriverAgent] Sim: environment = {
[debug] [WebDriverAgent] Sim: "DTX_CONNECTION_SERVICES_PATH" = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/Developer/Library/PrivateFrameworks/DTXConnectionServices.framework";
[debug] [WebDriverAgent] Sim: "DYLD_FRAMEWORK_PATH" = "/Users/abc/Library/Developer/Xcode/DerivedData/WebDriverAgent-dfdievcxyrzumfawcyrwmemylwmf/Build/Products/Debug-iphonesimulator:/Users/abc/Library/Developer/Xcode/DerivedData/WebDriverAgent-dfdievcxyrzumfawcyrwmemylwmf/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks";
[debug] [WebDriverAgent] Sim: "DYLD_LIBRARY_PATH" = "/Users/abc/Library/Developer/Xcode/DerivedData/WebDriverAgent-dfdievcxyrzumfawcyrwmemylwmf/Build/Products/Debug-iphonesimulator:/Users/abc/Library/Developer/Xcode/DerivedData/WebDriverAgent-dfdievcxyrzumfawcyrwmemylwmf/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks";
[debug] [WebDriverAgent] Sim: NSUnbufferedIO = YES;
[debug] [WebDriverAgent] Sim: "OS_ACTIVITY_DT_MODE" = YES;
[debug] [WebDriverAgent] Sim: "XCODE_DBG_XPC_EXCLUSIONS" = "com.apple.dt.xctestSymbolicator";
[debug] [WebDriverAgent] Sim: XCTestConfigurationFilePath = "/var/folders/1m/6m0n2ph10nz85p68w8375m7m01h5tx/T/com.apple.dt.XCTest/C57F2807-C575-45B3-A431-75FC989D8FE8/remote-container/tmp/WebDriverAgentRunner-C57F2807-C575-45B3-A431-75FC989D8FE8.xctestconfiguration";
[debug] [WebDriverAgent] Sim: "__XCODE_BUILT_PRODUCTS_DIR_PATHS" = "/Users/abc/Library/Developer/Xcode/DerivedData/WebDriverAgent-dfdievcxyrzumfawcyrwmemylwmf/Build/Products/Debug-iphonesimulator";
[debug] [WebDriverAgent] Sim: "__XPC_DYLD_FRAMEWORK_PATH" = "/Users/abc/Library/Developer/Xcode/DerivedData/WebDriverAgent-dfdievcxyrzumfawcyrwmemylwmf/Build/Products/Debug-iphonesimulator";
[debug] [WebDriverAgent] Sim: "__XPC_DYLD_LIBRARY_PATH" = "/Users/abc/Library/Developer/Xcode/DerivedData/WebDriverAgent-dfdievcxyrzumfawcyrwmemylwmf/Build/Products/Debug-iphonesimulator";
[debug] [WebDriverAgent] Sim: };
[debug] [WebDriverAgent] Sim: stderr = "/dev/ttys002";
[debug] [WebDriverAgent] Sim: stdout = "/dev/ttys002";
[debug] [WebDriverAgent] Sim: "wait_for_debugger" = 0;
[debug] [WebDriverAgent] Sim: }
[debug] [WebDriverAgent] Sim: Oct 13 12:42:53 CoreSimulatorBridge[37846]: [Common] [FBSSystemService][0x6315] Sending request to open "com.apple.test.WebDriverAgentRunner-Runner"
[debug] [WebDriverAgent] Sim: Oct 13 12:42:53 CoreSimulatorBridge[37846]: [Common] [FBSSystemService][0x6315] Request successful:
[debug] [WebDriverAgent] Sim: Oct 13 12:42:54 XCTRunner[38203]: assertion failed: 15G31 14A345: libxpc.dylib + 62597 [37A9DF49-35C1-3D93-B854-B35CACF0100F]: 0x7d
[debug] [WebDriverAgent] Sim: Oct 13 12:42:54 XCTRunner[38203]: Running tests...
[debug] [WebDriverAgent] Sim: Oct 13 12:43:00 --- last message repeated 4 times ---
[debug] [WebDriverAgent] Sim: Oct 13 12:43:00 XCTRunner[38203]: Continuing to run tests in the background with task ID 1
[debug] [WebDriverAgent] Sim: Oct 13 12:43:00 --- last message repeated 13 times ---
[debug] [WebDriverAgent] Sim: Oct 13 12:43:00 XCTRunner[38203]: Built at Oct 13 2016 12:42:49
[XCUITest] Detected that WebDriverAgent is running at url 'http://10.165.64.160:8100'
[debug] [WebDriverAgent] Sim: Oct 13 12:43:00 XCTRunner[38203]: ServerURLHere->http://10.165.64.160:8100<-ServerURLHere
[XCUITest] WebDriverAgent started at url 'http://10.165.64.160:8100'
[JSONWP Proxy] Proxying [POST /session] to [POST http://localhost:8100/session] with body: {"desiredCapabilities":{"bu...
[XCUITest] SyntaxError: Unexpected token < in JSON at position 0
at Object.parse (native)
at new ProxyRequestError (lib/mjsonwp/errors.js:322:26)
at JWProxy.proxy$ (lib/jsonwp-proxy/proxy.js:122:13)
at tryCatch (/Users/abc/Downloads/appium-1.6.0/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (/Users/abc/Downloads/appium-1.6.0/node_modules/babel-runtime/regenerator/runtime.js:136:37)
SyntaxError: Unexpected token < in JSON at position 0
at Object.parse (native)
at new ProxyRequestError (lib/mjsonwp/errors.js:322:26)
at JWProxy.proxy$ (lib/jsonwp-proxy/proxy.js:122:13)
at tryCatch (/Users/abc/Downloads/appium-1.6.0/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (/Users/abc/Downloads/appium-1.6.0/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[JSONWP Proxy] Proxying [DELETE /session/458b8ebe-d810-42f0-806d-ca5b6edb5de5] to [DELETE http://localhost:8100/session/458b8ebe-d810-42f0-806d-ca5b6edb5de5] with no body
[MJSONWP] Encountered internal error running command: SyntaxError: Unexpected token < in JSON at position 0
at Object.parse (native)
at new ProxyRequestError (lib/mjsonwp/errors.js:322:26)
at JWProxy.proxy$ (lib/jsonwp-proxy/proxy.js:122:13)
at tryCatch (/Users/abc/Downloads/appium-1.6.0/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (/Users/abc/Downloads/appium-1.6.0/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[HTTP] <-- POST /wd/hub/session 500 32786 ms - 177
[debug] [XCUITest] Waiting for WebDriverAgent server to finish loading...
[debug] [XCUITest] Waiting for WebDriverAgent server to finish loading...

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:38 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
hemchecommented, Dec 18, 2016

I had been following this thread for sometime, the corporate proxy was the culprit. After removing proxy details in bash profile. The app launched like a charm ! Thank you @imurchie @wmkeicher @vishwathma

1reaction
imurchiecommented, Oct 27, 2016

You should be able to set your no_proxy for a particular port, so you can narrow it down to the particular Appium port on localhost. Unless you randomly assign the port when running.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: Unexpected token < in JSON at position 0 ...
You suddenly got the error because the server didn't respond JSON data. It can be server error (500) or client bad data (4xx)....
Read more >
Unable to start WebDriverAgent - Unexpected token < in JSON
[XCUITest] SyntaxError: Unexpected token < in JSON at position 0 at Object.parse (native)
Read more >
Unexpected token < in JSON at position 0 - Dave Ceddia
The root cause is that the server returned HTML or some other non-JSON string. Why would it do that? “Unexpected token o in...
Read more >
SyntaxError: Unexpected token/in JSON at position || Firebase ...
I'm trying to deploy a project with firebase init. When I get to the part that asks me this: "What file should be...
Read more >
SyntaxError : Unexpected token in JSON at position 0 - YouTube
Fix: Uncaught SyntaxError Unexpected token in JSON at position 0__________________________________________▶️ Say "Hello ‍♂️" to me ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found