How to launch ios_webkit_debug_proxy using java code

does any one know how to launch ios_webkit_debug_proxy using java code and capture log to make a check if iPhone is connected ?

Thanks in advance!

Not sure about how to do it in Java, but in Python I do 2 things:

  • For verifying if an iPhone is connected I use:
class connected_iPhones(): def __init__(self): sp = Popen("system_profiler SPUSBDataType -xml", shell=True, stdout=PIPE).communicate()[0] sys_plist = readPlistFromString(sp)[0] allowed_devices = ['iphone', 'ipad'] self.connected_devices = {}
    for item in sys_plist.get('_items'):
        for k, v in item.items():
            if k == '_items':
                for device in v:
                    if device.get('_name').lower() in allowed_devices:
                        self.connected_devices[device.get('serial_num')] = v
                    else:
                        sub_array = device.get('_items')
                        if sub_array is not None:
                            for device in sub_array:
                                if device.get('_name').lower() in allowed_devices:
                                    self.connected_devices[device.get('serial_num')] = device

This returns a list of connected devices.

  • For launching the ios_webkit_debug_proxy I launch a subprocess with the command ā€˜/usr/local/bin/node appium --port=%d’ % self.port (Change port and directory as required. then I send the stdout and stderr to a temprorary log file that I can retrieve once the test is done. Use Java to launch and kill the Appium process