def __init__(self,
                 server_url,
                 chrome_binary=None,
                 android_package=None,
                 chrome_switches=None,
                 chrome_extensions=None,
                 chrome_log_path=None):
        self._executor = command_executor.CommandExecutor(server_url)

        options = {}
        if android_package:
            options['androidPackage'] = android_package
        elif chrome_binary:
            options['binary'] = chrome_binary

        if chrome_switches:
            assert type(chrome_switches) is list
            options['args'] = chrome_switches

        if chrome_extensions:
            assert type(chrome_extensions) is list
            options['extensions'] = chrome_extensions

        if chrome_log_path:
            assert type(chrome_log_path) is str
            options['logPath'] = chrome_log_path

        params = {'desiredCapabilities': {'chromeOptions': options}}

        self._session_id = self._executor.Execute(Command.NEW_SESSION,
                                                  params)['sessionId']
Ejemplo n.º 2
0
  def __init__(self, server_url, chrome_binary=None, android_package=None,
               android_activity=None, android_process=None,
               android_use_running_app=None, chrome_switches=None,
               chrome_extensions=None, chrome_log_path=None,
               debugger_address=None, browser_log_level=None,
               experimental_options=None):
    self._executor = command_executor.CommandExecutor(server_url)

    options = {}

    if experimental_options:
      assert isinstance(experimental_options, dict)
      options = experimental_options.copy()

    if android_package:
      options['androidPackage'] = android_package
      if android_activity:
        options['androidActivity'] = android_activity
      if android_process:
        options['androidProcess'] = android_process
      if android_use_running_app:
        options['androidUseRunningApp'] = android_use_running_app
    elif chrome_binary:
      options['binary'] = chrome_binary

    if chrome_switches:
      assert type(chrome_switches) is list
      options['args'] = chrome_switches

    if chrome_extensions:
      assert type(chrome_extensions) is list
      options['extensions'] = chrome_extensions

    if chrome_log_path:
      assert type(chrome_log_path) is str
      options['logPath'] = chrome_log_path

    if debugger_address:
      assert type(debugger_address) is str
      options['debuggerAddress'] = debugger_address

    logging_prefs = {}
    log_levels = ['ALL', 'DEBUG', 'INFO', 'WARNING', 'SEVERE', 'OFF']
    if browser_log_level:
      assert browser_log_level in log_levels
      logging_prefs['browser'] = browser_log_level

    params = {
      'desiredCapabilities': {
        'chromeOptions': options,
        'loggingPrefs': logging_prefs
      }
    }

    response = self._ExecuteCommand(Command.NEW_SESSION, params)
    self._session_id = response['sessionId']
    self.capabilities = self._UnwrapValue(response['value'])
Ejemplo n.º 3
0
    def __init__(self, ipAddress, isThisLinux):
        """
        Opens a socket for the specified IP address that listens for commands from the client (volume change, seek, play/pause, etc);
        """
        self.ip = str(ipAddress)
        self.isThisLinux = isThisLinux
        self.commandExecutor = command_executor.CommandExecutor(isThisLinux)
        self.startServer()

        while 1:
            secureClientSocket = self.acceptConnections()
            self.receiveMessages(secureClientSocket)
Ejemplo n.º 4
0
    def __init__(self,
                 server_url,
                 chrome_binary=None,
                 android_package=None,
                 chrome_switches=None,
                 chrome_extensions=None,
                 chrome_log_path=None,
                 debugger_address=None,
                 browser_log_level=None):
        self._executor = command_executor.CommandExecutor(server_url)

        options = {}
        if android_package:
            options['androidPackage'] = android_package
        elif chrome_binary:
            options['binary'] = chrome_binary

        if chrome_switches:
            assert type(chrome_switches) is list
            options['args'] = chrome_switches

        if chrome_extensions:
            assert type(chrome_extensions) is list
            options['extensions'] = chrome_extensions

        if chrome_log_path:
            assert type(chrome_log_path) is str
            options['logPath'] = chrome_log_path

        if debugger_address:
            assert type(debugger_address) is str
            options['debuggerAddress'] = debugger_address

        logging_prefs = {}
        log_levels = ['ALL', 'DEBUG', 'INFO', 'WARNING', 'SEVERE', 'OFF']
        if browser_log_level:
            assert browser_log_level in log_levels
            logging_prefs['browser'] = browser_log_level

        params = {
            'desiredCapabilities': {
                'chromeOptions': options,
                'loggingPrefs': logging_prefs
            }
        }

        self._session_id = self._ExecuteCommand(Command.NEW_SESSION,
                                                params)['sessionId']
    def __init__(self, logfile, server, chrome_binary, base_url=None):
        """Initialize the Replayer instance.

    Args:
      logfile: log file handle object to replay from.
      options: command-line options; see below. Needs at least
        options.chromedriver for the ChromeDriver binary.
      base_url: string, base of the url to replace in the logged urls (useful
      for when ports change). If any value is passed here, it overrides any
        base url passed in options.
    """

        # TODO(cwinstanley) Add Android support and perhaps support for other
        # chromedriver command line options.
        self.executor = command_executor.CommandExecutor(server.GetUrl())
        self.command_sequence = CommandSequence(logfile,
                                                base_url=base_url,
                                                chrome_binary=chrome_binary)
Ejemplo n.º 6
0
  def _InternalInit(self, server_url, chrome_binary=None, android_package=None,
      android_activity=None, android_process=None,
      android_use_running_app=None, chrome_switches=None,
      chrome_extensions=None, chrome_log_path=None,
      debugger_address=None, logging_prefs=None,
      mobile_emulation=None, experimental_options=None,
      download_dir=None, network_connection=None,
      send_w3c_capability=None, send_w3c_request=None,
      page_load_strategy=None, unexpected_alert_behaviour=None,
      devtools_events_to_log=None, accept_insecure_certs=None,
      timeouts=None, test_name=None):
    self._executor = command_executor.CommandExecutor(server_url)
    self.w3c_compliant = False

    options = {}

    if experimental_options:
      assert isinstance(experimental_options, dict)
      options = experimental_options.copy()

    if android_package:
      options['androidPackage'] = android_package
      if android_activity:
        options['androidActivity'] = android_activity
      if android_process:
        options['androidProcess'] = android_process
      if android_use_running_app:
        options['androidUseRunningApp'] = android_use_running_app
    elif chrome_binary:
      options['binary'] = chrome_binary

    if sys.platform.startswith('linux') and android_package is None:
      if chrome_switches is None:
        chrome_switches = []
      # Workaround for crbug.com/611886.
      chrome_switches.append('no-sandbox')
      # https://bugs.chromium.org/p/chromedriver/issues/detail?id=1695
      chrome_switches.append('disable-gpu')

    if chrome_switches is None:
      chrome_switches = []
    chrome_switches.append('force-color-profile=srgb')

    if chrome_switches:
      assert type(chrome_switches) is list
      options['args'] = chrome_switches

    if mobile_emulation:
      assert type(mobile_emulation) is dict
      options['mobileEmulation'] = mobile_emulation

    if chrome_extensions:
      assert type(chrome_extensions) is list
      options['extensions'] = chrome_extensions

    if chrome_log_path:
      assert type(chrome_log_path) is str
      options['logPath'] = chrome_log_path

    if debugger_address:
      assert type(debugger_address) is str
      options['debuggerAddress'] = debugger_address

    if logging_prefs:
      assert type(logging_prefs) is dict
      log_types = ['client', 'driver', 'browser', 'server', 'performance',
        'devtools']
      log_levels = ['ALL', 'DEBUG', 'INFO', 'WARNING', 'SEVERE', 'OFF']
      for log_type, log_level in logging_prefs.iteritems():
        assert log_type in log_types
        assert log_level in log_levels
    else:
      logging_prefs = {}

    if devtools_events_to_log:
      assert type(devtools_events_to_log) is list
      options['devToolsEventsToLog'] = devtools_events_to_log

    download_prefs = {}
    if download_dir:
      if 'prefs' not in options:
        options['prefs'] = {}
      if 'download' not in options['prefs']:
        options['prefs']['download'] = {}
      options['prefs']['download']['default_directory'] = download_dir

    if send_w3c_capability:
      options['w3c'] = send_w3c_capability

    params = {
        'goog:chromeOptions': options,
        'loggingPrefs': logging_prefs
    }

    if page_load_strategy:
      assert type(page_load_strategy) is str
      params['pageLoadStrategy'] = page_load_strategy

    if unexpected_alert_behaviour:
      assert type(unexpected_alert_behaviour) is str
      if send_w3c_request:
        params['unhandledPromptBehavior'] = unexpected_alert_behaviour
      else:
        params['unexpectedAlertBehaviour'] = unexpected_alert_behaviour

    if network_connection:
      params['networkConnectionEnabled'] = network_connection

    if accept_insecure_certs is not None:
      params['acceptInsecureCerts'] = accept_insecure_certs

    if timeouts is not None:
      params['timeouts'] = timeouts

    if test_name is not None:
      params['goog:testName'] = test_name

    if send_w3c_request:
      params = {'capabilities': {'alwaysMatch': params}}
    else:
      params = {'desiredCapabilities': params}

    response = self._ExecuteCommand(Command.NEW_SESSION, params)
    if len(response.keys()) == 1 and 'value' in response.keys():
      self.w3c_compliant = True
      self._session_id = response['value']['sessionId']
      self.capabilities = self._UnwrapValue(response['value']['capabilities'])
    elif isinstance(response['status'], int):
      self.w3c_compliant = False
      self._session_id = response['sessionId']
      self.capabilities = self._UnwrapValue(response['value'])
    else:
      raise UnknownError("unexpected response")
Ejemplo n.º 7
0
  def __init__(self, server_url, chrome_binary=None, android_package=None,
               android_activity=None, android_process=None,
               android_use_running_app=None, chrome_switches=None,
               chrome_extensions=None, chrome_log_path=None,
               debugger_address=None, logging_prefs=None,
               mobile_emulation=None, experimental_options=None,
               download_dir=None):
    self._executor = command_executor.CommandExecutor(server_url)

    options = {}

    if experimental_options:
      assert isinstance(experimental_options, dict)
      options = experimental_options.copy()

    if android_package:
      options['androidPackage'] = android_package
      if android_activity:
        options['androidActivity'] = android_activity
      if android_process:
        options['androidProcess'] = android_process
      if android_use_running_app:
        options['androidUseRunningApp'] = android_use_running_app
    elif chrome_binary:
      options['binary'] = chrome_binary

    if chrome_switches:
      assert type(chrome_switches) is list
      options['args'] = chrome_switches

    if mobile_emulation:
      assert type(mobile_emulation) is dict
      options['mobileEmulation'] = mobile_emulation

    if chrome_extensions:
      assert type(chrome_extensions) is list
      options['extensions'] = chrome_extensions

    if chrome_log_path:
      assert type(chrome_log_path) is str
      options['logPath'] = chrome_log_path

    if debugger_address:
      assert type(debugger_address) is str
      options['debuggerAddress'] = debugger_address

    if logging_prefs:
      assert type(logging_prefs) is dict
      log_types = ['client', 'driver', 'browser', 'server', 'performance']
      log_levels = ['ALL', 'DEBUG', 'INFO', 'WARNING', 'SEVERE', 'OFF']
      for log_type, log_level in logging_prefs.iteritems():
        assert log_type in log_types
        assert log_level in log_levels
    else:
      logging_prefs = {}

    download_prefs = {}
    if download_dir:
      if 'prefs' not in options:
        options['prefs'] = {}
      if 'download' not in options['prefs']:
        options['prefs']['download'] = {}
      options['prefs']['download']['default_directory'] = download_dir

    params = {
      'desiredCapabilities': {
        'chromeOptions': options,
        'loggingPrefs': logging_prefs
      }
    }

    response = self._ExecuteCommand(Command.NEW_SESSION, params)
    self._session_id = response['sessionId']
    self.capabilities = self._UnwrapValue(response['value'])
Ejemplo n.º 8
0
    def __init__(self,
                 server_url,
                 chrome_binary=None,
                 android_package=None,
                 android_activity=None,
                 android_process=None,
                 android_use_running_app=None,
                 chrome_switches=None,
                 chrome_extensions=None,
                 chrome_log_path=None,
                 debugger_address=None,
                 logging_prefs=None,
                 mobile_emulation=None,
                 experimental_options=None,
                 download_dir=None,
                 network_connection=None,
                 send_w3c_capability=None,
                 send_w3c_request=None,
                 page_load_strategy=None,
                 unexpected_alert_behaviour=None):
        self._executor = command_executor.CommandExecutor(server_url)

        options = {}

        if experimental_options:
            assert isinstance(experimental_options, dict)
            options = experimental_options.copy()

        if android_package:
            options['androidPackage'] = android_package
            if android_activity:
                options['androidActivity'] = android_activity
            if android_process:
                options['androidProcess'] = android_process
            if android_use_running_app:
                options['androidUseRunningApp'] = android_use_running_app
        elif chrome_binary:
            options['binary'] = chrome_binary

        # TODO(samuong): speculative fix for crbug.com/611886
        if (sys.platform.startswith('linux')
                and platform.architecture()[0] == '32bit'):
            if chrome_switches is None:
                chrome_switches = []
            chrome_switches.append('no-sandbox')

        if chrome_switches:
            assert type(chrome_switches) is list
            options['args'] = chrome_switches

        if mobile_emulation:
            assert type(mobile_emulation) is dict
            options['mobileEmulation'] = mobile_emulation

        if chrome_extensions:
            assert type(chrome_extensions) is list
            options['extensions'] = chrome_extensions

        if chrome_log_path:
            assert type(chrome_log_path) is str
            options['logPath'] = chrome_log_path

        if debugger_address:
            assert type(debugger_address) is str
            options['debuggerAddress'] = debugger_address

        if logging_prefs:
            assert type(logging_prefs) is dict
            log_types = [
                'client', 'driver', 'browser', 'server', 'performance'
            ]
            log_levels = ['ALL', 'DEBUG', 'INFO', 'WARNING', 'SEVERE', 'OFF']
            for log_type, log_level in logging_prefs.iteritems():
                assert log_type in log_types
                assert log_level in log_levels
        else:
            logging_prefs = {}

        download_prefs = {}
        if download_dir:
            if 'prefs' not in options:
                options['prefs'] = {}
            if 'download' not in options['prefs']:
                options['prefs']['download'] = {}
            options['prefs']['download']['default_directory'] = download_dir

        if send_w3c_capability:
            options['w3c'] = send_w3c_capability

        params = {
            'desiredCapabilities': {
                'chromeOptions': options,
                'loggingPrefs': logging_prefs
            }
        }

        if page_load_strategy:
            assert type(page_load_strategy) is str
            params['desiredCapabilities'][
                'pageLoadStrategy'] = page_load_strategy

        if unexpected_alert_behaviour:
            assert type(unexpected_alert_behaviour) is str
            params['desiredCapabilities']['unexpectedAlertBehaviour'] = (
                unexpected_alert_behaviour)

        if network_connection:
            params['desiredCapabilities']['networkConnectionEnabled'] = (
                network_connection)

        if send_w3c_request:
            params = {'capabilities': params}

        response = self._ExecuteCommand(Command.NEW_SESSION, params)
        if isinstance(response['status'], basestring):
            self.w3c_compliant = True
        elif isinstance(response['status'], int):
            self.w3c_compliant = False
        else:
            raise UnknownError("unexpected response")

        self._session_id = response['sessionId']
        self.capabilities = self._UnwrapValue(response['value'])