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.

iOS Appium giving error: TypeError: Cannot read property 'wasThrown' of undefined

See original GitHub issue

Problem: I have upgraded XCode to 9 and Appium to 1.7/1.6.5 and trying to execute few test cases on mobile web. Code:

_DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "iPhone");
capabilities.setCapability("udid", "<udid>");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("automationName", "XCUITest");
capabilities.setCapability("browserName", "Safari");
capabilities.setCapability("newCommandTimeout",180);
capabilities.setCapability("webkitResponseTimeout", 70000);
capabilities.setCapability("networkConnectionEnabled",true);
capabilities.setCapability("--session-override",true);
		
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Thread.sleep(5000);
driver.get("https://<url>");
Thread.sleep(10000);
driver.findElement(By.xpath("//*[@id='<>']")).click();_

Sometimes the test case run properly but sometimes it gives error as mentioned below: Sep 22, 2017 9:19:00 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS Exception in thread “main” org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died. Build info: version: ‘3.5.3’, revision: ‘', time: '2017-08-29T12:42:44.’ System info: host: ‘MacBook-Pro.local’, ip: ‘’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.12.6’, java.version: ‘1.8.0_40’ Driver info: driver.version: RemoteWebDriver Capabilities [{networkConnectionEnabled=true, webkitResponseTimeout=70000, --session-override=true, databaseEnabled=false, deviceName=iPhone, platform=MAC, newCommandTimeout=180, webStorageEnabled=false, locationContextEnabled=false, automationName=XCUITest, browserName=Safari, takesScreenshot=true, javascriptEnabled=true, udid=<udid>, platformName=MAC}] Session ID: at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:667) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:416) at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:518) at org.openqa.selenium.By$ByXPath.findElement(By.java:361) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:408) at com.appium_ios11.testExec.main(testExec.java:64) Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:4723 [/127.0.0.1] failed: Connection refused at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359) at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:139) at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:87) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:161) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:646) … 5 more Caused by: java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) … 18 more

Also, on looking at appium server logs, I get the below error:

_[debug] [RemoteDebugger] Webkit response timeout: 70000
[debug] [RemoteDebugger] Receiving WebKit data: {"result":{"result":{"type":"string","value":"{\"status\":0,\"value\":null}"},"wasThrown":false},"id":3}
[debug] [RemoteDebugger] Found handler for message '3'
[debug] [RemoteDebugger] Received result for atom 'click' execution: null
[debug] [MJSONWP] Responding to client with driver.click() result: null
[HTTP] <-- POST /wd/hub/session/**/element/5000/click 200 942 ms - 76 
[debug] [RemoteDebugger] Receiving WebKit data: {"method":"Canvas.canvasMemoryChanged","params":{"canvasId":"canvas:0.3","memoryCost":32000}}
TypeError: Cannot read property 'wasThrown' of undefined
    at WebKitRpcClient.receive (../../lib/webkit-rpc-client.js:117:38)
    at emitTwo (events.js:106:13)
    at WebSocket.emit (events.js:191:7)
    at Receiver.ontext (/usr/local/lib/node_modules/appium/node_modules/ws/lib/WebSocket.js:841:10)
    at /usr/local/lib/node_modules/appium/node_modules/ws/lib/Receiver.js:536:18
    at Receiver.applyExtensions (/usr/local/lib/node_modules/appium/node_modules/ws/lib/Receiver.js:371:5)
    at /usr/local/lib/node_modules/appium/node_modules/ws/lib/Receiver.js:508:14
    at Receiver.flush (/usr/local/lib/node_modules/appium/node_modules/ws/lib/Receiver.js:347:3)
    at Receiver.finish (/usr/local/lib/node_modules/appium/node_modules/ws/lib/Receiver.js:541:12)
    at Receiver.expectHandler (/usr/local/lib/node_modules/appium/node_modules/ws/lib/Receiver.js:499:31)
    at Receiver.add (/usr/local/lib/node_modules/appium/node_modules/ws/lib/Receiver.js:103:24)
    at Socket.realHandler (/usr/local/lib/node_modules/appium/node_modules/ws/lib/WebSocket.js:825:20)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at TCP.onread (net.js:548:20)_

Can any one please help…

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
imurchiecommented, Sep 25, 2017

I’ve fixed this issue in appium-remote-debugger@3.6.2. If you re-install Appium it should work (npm uninstall -g appium && npm install -g appium --no-shrinkwrap).

0reactions
lock[bot]commented, Apr 25, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unhandled error: TypeError: Cannot read property 'path' of ...
error : Unhandled error: TypeError: Cannot read property 'path' of undefined. This issue get resolved when i delete by code and checkout again...
Read more >
Appium error: uncaughtException: Cannot read property ...
But still facing some problem in appium that Appium is stopped certainly giving an uncaught exception: Cannot read property 'executeAtom' of null.
Read more >
appium/appium - Gitter
When I try running a test on iOS I keep getting the following error: ... automationName to Flutter is causing a cannot read...
Read more >
cannot read properties of null (reading 'command') - You.com
toString(), status, error); ^ TypeError: Cannot read properties of null (reading 'toString') ... Xcode - develop for iOS and macOS (Xcode 12.4) •...
Read more >
Uncaught TypeError: Cannot read property of undefined
The error most often than not is faced when the scripts come across uninitialized variable or object. Description. 'Undefined' is the property ......
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