Operation timed out while switching to webview context in Appium 1.13

Hi,

I am trying to switch to web view context to interact with few web elements in the hybrid app. I am using the debug build and I am able to get all the web view and native contexts. Only when I am trying to switch to the web view context, it throws the time out exception. The configuration is as follows. I have also attached the log. I was not facing this issue in the older version(1.7) of appium.

      cap.setCapability("deviceName", "*****");
      cap.setCapability("deviceOrientation", "portrait");
      cap.setCapability("platformVersion", "12.2");
      cap.setCapability("platformName", "iOS");
      cap.setCapability("udid", "********");
      cap.setCapability("bundleId", "******");
      cap.setCapability("automationName", "XCUITest");
      cap.setCapability("newCommandTimeout", "120");
      cap.setCapability("webkitResponseTimeout", "20000");

I am using Appium version 1.13.0, Xcode version 10.2.1, Appium Java client 6.1.0, Selenium version 3.141.59.

When driver.context(s); is executed, it throws following exception

io.appium.java_client.NoSuchContextException: An unknown server-side error occurred while processing the command. Original error: operation timed out

Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’

System info: host: ‘*******’, ip: ‘********’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.14.5’, java.version: ‘1.8.0_25’

Driver info: io.appium.java_client.ios.IOSDriver

Capabilities {automationName: Appium, browserName: , bundleId: ********, databaseEnabled: false, deviceName: ********, deviceOrientation: portrait, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: false, newCommandTimeout: 120, platform: MAC, platformName: iOS, platformVersion: 12.2, takesScreenshot: true, udid: ***********…, webStorageEnabled: false, webkitResponseTimeout: 20000}

Session ID: 909d73ee-ff55-4d35-8777-05b9e675a1df

at io.appium.java_client.AppiumDriver.context(AppiumDriver.java:201)

at TestScript.main(TestScript.java:43)

Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: operation timed out

Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’

System info: host: ‘’, ip: '’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.14.5’, java.version: ‘1.8.0_25’

Driver info: io.appium.java_client.ios.IOSDriver

Capabilities {automationName: Appium, browserName: , bundleId: *************, databaseEnabled: false, deviceName: *************, deviceOrientation: portrait, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: false, newCommandTimeout: 120, platform: MAC, platformName: iOS, platformVersion: 12.2, takesScreenshot: true, udid: *************…, webStorageEnabled: false, webkitResponseTimeout: 20000}

Session ID: 909d73ee-ff55-4d35-8777-05b9e675a1df

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:408)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)

at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)

at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231)

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)

at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)

at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)

at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)

at io.appium.java_client.AppiumDriver.context(AppiumDriver.java:198)

… 1 more

@Suryakanta_Mohapatra
Make sure your ios-webkit-debug-proxy is up to date as per 1.13 release notes

if it is up to date then try this :

before switching to any context first print all available context using
System.out.println(driver.getContextHandles());

check for correct name of context

@PramodKarande
Thanks for the response. I still see the issue. As per 1.13 release notes, I should have 1.8.4 ios_webkit_debug_proxy.

I do have ios_webkit_debug_proxy 1.8.4, as mentioned below.

$ ios_webkit_debug_proxy --version
ios_webkit_debug_proxy 1.8.4
Built with libimobiledevice v1.2.0, libplist v2.0.0

Followings are the response from the Appium log:

[debug] [RemoteDebugger] Webkit response timeout: 20000
[debug] [RemoteDebugger] Received WebKit data: ‘{“result”:{},“id”:1}’
[debug] [RemoteDebugger] Received receipt for message ‘1’
[debug] [W3C (41bc414b)] Encountered internal error running command: TimeoutError: operation timed out
[debug] [W3C (41bc414b)] at afterTimeout (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/release/timers.js:46:19)
[debug] [W3C (41bc414b)] at Timeout.timeoutTimeout [as _onTimeout] (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/release/timers.js:76:13)
[debug] [W3C (41bc414b)] at listOnTimeout (timers.js:324:15)
[debug] [W3C (41bc414b)] at processTimers (timers.js:268:5)
[HTTP] <-- POST /wd/hub/session/41bc414b-7f7e-45fe-937a-19a1a88c2ecc/context 500 20012 ms - 535

Followings are the log from eclipse:

Context name [NATIVE_APP, WEBVIEW_13, WEBVIEW_14, WEBVIEW_17]
Context is -> NATIVE_APP

io.appium.java_client.NoSuchContextException: An unknown server-side error occurred while processing the command. Original error: operation timed out
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘DNVCOML-N2YNG8W’, ip: ‘fe80:0:0:0:10e8:b972:af1:38b%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.14.5’, java.version: ‘1.8.0_25’
Driver info: io.appium.java_client.ios.IOSDriver

As can be seen, I can get the Web view context before doing the context switch. For the Native app context switching, it does not throw an exception. As soon as it tries to switch to WEBVIEW_13, NoSuchContextException is thrown.

Please let me know if I’m missing anything.

@Suryakanta_Mohapatra
As per my experience with same kind of scenario
this webview context names keep on changing every run.
do not hard code it as driver.context(“WEBVIEW_13”)

run your code 3-4 times and observe names given by System.out.println(driver.getContextHandles());

you have to select context name at run time instead of static.
try below code

Set h=driver.getContextHandles();
String web="";

for(int i=0;i<h.size();i++)
{
web=new ArrayList<>(h).get(i);
System.out.println(web);
if(web.contains(“WEBVIEW”))
{
driver.context(web);
break;
}

}

@PramodKarande
I did not hard code. I’m switching to the appropriate one irrespective of _13 or _14. I am sure I am switching to the correct web context as I tested this by debugging.

Other than above, do you have any different thought?

@Suryakanta_Mohapatra
how you are sure about context?
Show your code to switch to context!

@PramodKarande

Here is the code. As I said, the very first time it tries to switch to the web view context, it goes to the exception (nosuchcontextexception). And I am debugging it step by step.

Below is the snapshot of the exception log.

It is clear that I am having the correct version of ios_webkit_debug_proxy (1.8.4) and also getting web contexts. Only during switching, it throws an exception. Thoughts?

@Suryakanta_Mohapatra
I have replicated same scenario at my end with same setup as your’s and i am able to switch to webview.
only difference is i am using java client 7.0.0

try updating your Java client

Hi
@Suryakanta_Mohapatra
is the issue resolved or still exists?

1)Make sure no safari is running on device.

2)what version of device OS using? is it iOS 12.2?

ios_webkit_debug_proxy -c :27753 -d
is there any error code is receiving in console like below or any other
Ex :
Error code":-32601,“message”:
“‘Runtime’ domain w
as not found”,“data
“:[{“code”:-32601,”
message”:"‘Runtime’
domain was not found"}]},}

reinstall below items , hope this will work
brew update
brew reinstall usbmuxd (or ) brew install --HEAD usbmuxd
brew reinstall libimobiledevice
brew reinstall -s ios-webkit-debug-proxy — before reintnstall we might need to unlink

Hi @RamaraoR,

I am still having the issue. I have java client 7.0.0. No safari running. Yes, I have 12.2 iOS device. Webkit proxy is 1.8.4. Not getting any error code.

@Suryakanta_Mohapatra
If possible can you share appium server logs
Reinstall above components and give try

Im also facing the same issue any update on this issue?