Built-in ios-webkit-debug-proxy server?

That would be great having option for server like --ios-webkit-debug-proxy -udid port, etc…
Are you planning to do something like that?
Thank you.

2 Likes

Yes this would be a great add on to appium

Actually they created JavaScript file to run webkit.

So ./bin/ios-webkit-debug-proxy-launcher.js -c :27753 -d is the command i will need to run it?
Where is the .js file actualy located?

Yeah, just run like that, except don’t forget to put UDID before :27753. This script is located in Appium/bin folder, if you run from source code.

1 Like

Hi kirill,
Have you tried executing the above command programaticaly?

Yes. I am doing that on Ruby:

 `pkill -f ios-webkit-debug-proxy-launcher ios_webkit_debug_proxy`
 `nohup node ~/appium/bin/ios-webkit-debug-proxy-launcher.js -c #{$device_udid}:27753 > /dev/null 2>&1 &`

You can do the same thing on any language. I restart webkit server before creating driver, to make sure server is not down, even though server is quite stable, sometimes it crashes randomly, but very seldom.

1 Like

Looks good will try it with Java.
Thanks Man :slight_smile:

Hi Mayuresh_Shirodkar,

I am unable to starting iOS webkit debug proxy server and get iPhone information. Could you please tell me, how to start iOS webkit debug proxy server from terminal using java code and how to get the iOS device information from terminal using java code. This is priority work for me.

Thanks in advance.

Why exactly you are not able to start proxy server? What kind of problem or error do you have? What iPhone information do you want to get?
In Ruby it’s easy to execute shell commands using backsticks (```). Essentially that’s basic shell script which you can be executed from Java as well:

String deviceId = "****";
Runtime.getRuntime().exec(new String[]{
        "pkill -f ios-webkit-debug-proxy-launcher ios_webkit_debug_proxy",
        ";",
        "nohup node ~/appium/bin/ios-webkit-debug-proxy-launcher.js -c " + deviceId + ":27753 > /dev/null 2>&1 &"
});

Hi kirill,

Thanks for reply. Actually I am able to run appium server and adb devices command on terminal using java code in mac , but I really don’t how to run command with spaces(Eg. ios-deploy -c) on terminal using java code.

Actually I am trying to get list of iPhone devices which are connected to mac machine using java code after that I am sending UDID, device name and device version of iPhone device to capabilities, but I am unable to get the iPhone data. please find the below java code.

Code 1: The below code is nothing displaying in console.

String[] str = {"/bin/bash", “-c”, “ios-deploy -c”};
Process p = Runtime.getRuntime().exec(str);
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = “”;
String allLine = “”;
while((line=r.readLine()) != null)
{
System.out.println(line);

}

Code 2: The below code is displaying IPhone information + Unnecessary data.
String[] str = {"/bin/bash", “-c”, “system_profiler”, “SPHardwareDataType”,"| sed -n -E -e ‘/(iPhone|iPad)/,/Serial/s/ *Serial Number: *(.+)/\1/p’" };

Process p = Runtime.getRuntime().exec(str);
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = “”;
String allLine = “”;
while((line=r.readLine()) != null)
{
System.out.println(line);

}

ios-webkit-debug-proxy Server:

I am getting below Exception when I trying to run ios-webkit-debug-proxy Server using below java code:
String deviceId = “xxxxxxxxxxxxxxxxxxxxxxxxxx”;
Process p = Runtime.getRuntime().exec(new String[]{
“pkill -f ios-webkit-debug-proxy-launcher ios_webkit_debug_proxy”,
“;”,
"nohup node ~/appium/bin/ios-webkit-debug-proxy-launcher.js -c " + deviceId + “:27753 > /dev/null 2>&1 &”
});
java.io.IOException: Cannot run program “pkill -f ios-webkit-debug-proxy-launcher ios_webkit_debug_proxy”: error=2, No such file or directory

Hi kirill,

Could you please tell me, how to start iOS webkit debug proxy server programmatically using java code. This is priority work for me.

Thanks in advance.

Hi kirill,

Could you please tell me, how to start Appium Server and iOS webkit debug proxy server programmatically using java code. This is priority work for me. how to fire the below commands on mac Terminal using java code.

Appium Server:

Directory : cd /Users/caaminf/appium/lib/server
Commande: node main.js -u

iOS webkit debug proxy:

Directory : cd /usr/local/bin/
Command: ios_webkit_debug_proxy -c :27753 -d

Currently I am trying the below ways, but not displaying any thing in java console.

Appium Server :

String[] cmd = { “/bin/sh”, “-c”, “cd /Users/caaminf/appium/lib/server; node main.js -U d2cd2a957b336b7a73cab93a1aefda6c5a1a” };
Process p = Runtime.getRuntime().exec(cmd);

	BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
	String line = "";
	String allLine = ""; 
	int i = 1;
	while((line=r.readLine()) != null)
	{
		System.out.println(line);
		i++;
	}

iOS webkit debug proxy:

String[] cmd = { “/bin/sh”, “-c”, “cd cd /usr/local/bin; ios_webkit_debug_proxy -c d2cd2a957b336b7a73cab93a1ae429efa1a:27753 -d” };
Process p = Runtime.getRuntime().exec(cmd);
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = “”;
String allLine = “”;
int i = 1;
while((line=r.readLine()) != null)
{
System.out.println(line);
i++;
}

Thanks in advance.

Hi Mayuresh,

Can you please share java code to start ios webkit debug proxy ?? Thanks

Hi,
At the moment i have added below commands in a shell script. and executing that shell script.
killall -9 ios_webkit_debug_proxy
ios_webkit_debug_proxy -c $UDID:27753

Hi Thanks Mayuresh for your quick reply. Another question after creating this shell script? How are you running this shell script in eclipse; I mean did you set any environment variable for ios_webkit_debug_proxy node ?? I am getting this error: env: node: Not a directory

Thank you in Advance!!

Hey if u r running it from eclipse… u need to set the PATH variable in the Run configurations… This will ensure u never get that error :slight_smile:

What path i need to set in eclipse for running ios_webkit_debug_proxy from eclipse?

PATH environment variable

How to run ios_webkit_debug_proxy with different port other than default port for appium 1.4.13 ?