def Create(self):
   backend = ios_browser_backend.IosBrowserBackend(
       self.finder_options.browser_options)
   return browser.Browser(backend,
                          self._platform_backend,
                          self._archive_path,
                          self._append_to_existing_wpr,
                          self._make_javascript_deterministic,
                          self._credentials_path)
Exemple #2
0
def FindAllAvailableBrowsers(finder_options, device):
    """Find all running iOS browsers on connected devices."""
    if not isinstance(device, ios_device.IOSDevice):
        return []

    if not CanFindAvailableBrowsers():
        return []

    options = finder_options.browser_options

    options.browser_type = 'ios-chrome'
    host = platform.GetHostPlatform()
    backend = ios_browser_backend.IosBrowserBackend(host, options)
    # TODO(baxley): Use idevice to wake up device or log debug statement.
    if not host.IsApplicationRunning(IOS_WEBKIT_DEBUG_PROXY):
        host.LaunchApplication(IOS_WEBKIT_DEBUG_PROXY)
        if not host.IsApplicationRunning(IOS_WEBKIT_DEBUG_PROXY):
            return []

    device_urls = backend.GetDeviceUrls()
    if not device_urls:
        logging.debug('Could not find any devices over %s.' %
                      IOS_WEBKIT_DEBUG_PROXY)
        return []

    debug_urls = backend.GetWebSocketDebuggerUrls(device_urls)

    # Get the userAgent for each UIWebView to find the browsers.
    browser_pattern = (r'\)\s(%s)\/(\d+[\.\d]*)\sMobile' %
                       '|'.join(IOS_BROWSERS.keys()))
    browser_types = set()
    for url in debug_urls:
        context = {'webSocketDebuggerUrl': url, 'id': 1}
        try:
            inspector = inspector_backend.InspectorBackend(
                backend.app, backend.devtools_client, context)
            res = inspector.EvaluateJavaScript("navigator.userAgent")
        finally:
            inspector.Disconnect()
        match_browsers = re.search(browser_pattern, res)
        if match_browsers:
            browser_types.add(match_browsers.group(1))

    browsers = []
    for browser_type in browser_types:
        browsers.append(
            PossibleIOSBrowser(IOS_BROWSERS[browser_type], finder_options))
    return list(browsers)
Exemple #3
0
 def Create(self, finder_options):
     browser_backend = ios_browser_backend.IosBrowserBackend(
         self._platform_backend, finder_options.browser_options)
     return browser.Browser(browser_backend, self._platform_backend,
                            self._credentials_path)