This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 13
Apr 2015

How to switch from a Native to WebView?When i use the below code:

String context=ElementsAction.driver.getContext();
System.out.println("Context Name" +context);
//Here my Context is getting printed as NativeAPP

		Set<String> contextNames = ElementsAction.driver.getContextHandles();
		for (String contextName : contextNames) {
		    System.out.println(contextName); //prints out something like NATIVE_APP \n WEBVIEW_1
		}

In the above code snippet,line 2 the Context gets printed as NativeAPP but i am trying to get the WEBAPP view,but that line 4 fails and throws below error message.

"An unknown server-side error occurred while processing the command. (Original error: connect ECONNREFUSED) (WARNING: The server did not provide any stacktrace information)"

Kindly help i am totally stuck.

Thanks

  • created

    Apr '15
  • last reply

    Sep '15
  • 12

    replies

  • 3.5k

    views

  • 4

    users

  • 6

    likes

  • 3

    links

You need to switch context to WEBVIEW_1 specifically. Then remember to switch back to NATIVE_APP before interacting with any native elements. Note the specific spellings of the contexts. Also, pay attention to hybrid views, I have seen the index the WEBVIEW can change from WEBVIEW_1 to WEBVIEW_3 etc.

An unknown server-side error occurred while processing the command. (Original error: connect ECONNREFUSED) (WARNING: The server did not provide any stacktrace information)"

This error must coming up may be coz u are using a real ios device.
You will require to connect to proxy using : ios_webkit_debug_proxy -c UDID:27753
This should solve your problem.

Try this it will solve ur problem:

Error: Could not connect to WebKitRemoteDebugger server.(ECONNREFUSED)
1. install ios_webkit_debug_proxy
2. Connect the device to the mac
3. In the terminal,enter command ios_webkit_debug_proxy –c udid:27753
At present Appium allows connection only at 27753 port. Also note that safari web inspector is enabled on the phone as well as on the desktop.
https://github.com/appium/appium/issues/277830
http://github.com/google/ios-webkit-debug-proxy28

@Mayuresh_Shirodkar
i tried installing ioS-webKit but got the below errors:

MACPC270917:~ 244325$ brew install ios-webkit-debug-proxy
-bash: brew: command not found

i even tried the below but its prompting for a password and when i give password,it throws error

MACPC270917:~ 244325$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
==> The following directories will be made group writable:
/usr/local/.
/usr/local/bin
/usr/local/lib
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man1
==> The following directories will have their group set to admin:
/usr/local/bin
/usr/local/lib
/usr/local/share/man
/usr/local/share/man/man1

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin /usr/local/lib /usr/local/share /usr/local/share/man /usr/local/share/man/man1
Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
Sorry, try again.
sudo: 3 incorrect password attempts
Failed during: /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin /usr/local/lib /usr/local/share /usr/local/share/man /usr/local/share/man/man1
MACPC270917:~ 244325$

Kindly help

12 days later

Thanks @Mayuresh_Shirodkar in getting this done.

Now i have got my webview by running this code :

      Set<String> getCont=ElementsAction.driver.getContextHandles();
		for(String switchCont:getCont)
		{
			System.out.println("get" +getCont);

Here it prints NATIVEAPP and WEBVIEW_1

			ElementsAction.driver.context(switchCont);
		}

But every time i run my app the WEBVIEW_1 is changing/incrementing [i.e WEBVIEW_1 then WEBVIEW_2 then WEBVIEW_3]

So my switch is not happening everytime..

@Mayuresh_Shirodkar yeah im using contains and now iam able to proceed further .. Thanks alot for your support..

Will get back to you if i have any issues.. Thanks alot again making me cross this overhead.

4 months later

ElementsAction - Where u got this one? how can we declare the elements?

That is a separate class holding all the functions.
Its actually my framework design.. nothing much