def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30, capabilities=None, proxy=None): self.binary = firefox_binary self.profile = firefox_profile if self.profile is None: self.profile = FirefoxProfile() self.profile.native_events_enabled = self.NATIVE_EVENTS_ALLOWED and self.profile.native_events_enabled if self.binary is None: self.binary = FirefoxBinary() if capabilities is None: capabilities = DesiredCapabilities.FIREFOX if proxy is not None: proxy.add_to_capabilities(capabilities) RemoteWebDriver.__init__(self, command_executor=ExtensionConnection( "127.0.0.1", self.profile, self.binary, timeout), desired_capabilities=capabilities) self._is_remote = False
def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30, capabilities=None, proxy=None, executable_path='wires'): self.binary = firefox_binary self.profile = firefox_profile if self.profile is None: self.profile = FirefoxProfile() self.profile.native_events_enabled = ( self.NATIVE_EVENTS_ALLOWED and self.profile.native_events_enabled) if capabilities is None: capabilities = DesiredCapabilities.FIREFOX if "marionette" in capabilities and capabilities['marionette'] is True: # Let's use Marionette! WOOOOHOOOOO! if "binary" in capabilities: self.binary = capabilities["binary"] self.service = Service(executable_path, firefox_binary=self.binary) self.service.start() RemoteWebDriver.__init__( self, command_executor=FirefoxRemoteConnection( remote_server_addr=self.service.service_url), desired_capabilities=capabilities, keep_alive=True) else: # Oh well... sometimes the old way is the best way. if self.binary is None: self.binary = FirefoxBinary() if proxy is not None: proxy.add_to_capabilities(capabilities) RemoteWebDriver.__init__(self, command_executor=ExtensionConnection( "127.0.0.1", self.profile, self.binary, timeout), desired_capabilities=capabilities, keep_alive=True) self._is_remote = False
def __init__(self, fx_profile=None, firefox_binary=None, timeout=30): self.binary = firefox_binary self.profile = fx_profile if self.profile is None: self.profile = FirefoxProfile() if self.binary is None: self.binary = FirefoxBinary() RemoteWebDriver.__init__(self, command_executor=ExtensionConnection("127.0.0.1", self.profile, self.binary, timeout), desired_capabilities=DesiredCapabilities.FIREFOX)
def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30, capabilities=None, proxy=None, executable_path="wires", firefox_options=None): capabilities = capabilities or DesiredCapabilities.FIREFOX.copy() self.profile = firefox_profile or FirefoxProfile() self.profile.native_events_enabled = ( self.NATIVE_EVENTS_ALLOWED and self.profile.native_events_enabled) self.binary = firefox_binary or capabilities.get( "binary", FirefoxBinary()) self.options = firefox_options or Options() self.options.binary_location = self.binary if isinstance( self.binary, basestring) else self.binary._get_firefox_start_cmd() self.options.profile = self.profile capabilities.update(self.options.to_capabilities()) # marionette if capabilities.get("marionette"): self.service = Service(executable_path, firefox_binary=self.options.binary_location) self.service.start() executor = FirefoxRemoteConnection( remote_server_addr=self.service.service_url) RemoteWebDriver.__init__(self, command_executor=executor, desired_capabilities=capabilities, keep_alive=True) else: # Oh well... sometimes the old way is the best way. if proxy is not None: proxy.add_to_capabilities(capabilities) executor = ExtensionConnection("127.0.0.1", self.profile, self.binary, timeout) RemoteWebDriver.__init__(self, command_executor=executor, desired_capabilities=capabilities, keep_alive=True) self._is_remote = False
def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30, capabilities=None, proxy=None, executable_path="wires"): self.binary = firefox_binary self.profile = firefox_profile if self.profile is None: self.profile = FirefoxProfile() self.profile.native_events_enabled = ( self.NATIVE_EVENTS_ALLOWED and self.profile.native_events_enabled) if capabilities is None: capabilities = DesiredCapabilities.FIREFOX # marionette if capabilities.get("marionette"): self.binary = capabilities.get("binary") self.service = Service(executable_path, firefox_binary=self.binary) self.service.start() executor = FirefoxRemoteConnection( remote_server_addr=self.service.service_url) RemoteWebDriver.__init__(self, command_executor=executor, desired_capabilities=capabilities, keep_alive=True) # use old Firefox add-on else: if self.binary is None: self.binary = FirefoxBinary() if proxy is not None: proxy.add_to_capabilities(capabilities) executor = ExtensionConnection("127.0.0.1", self.profile, self.binary, timeout) RemoteWebDriver.__init__(self, command_executor=executor, desired_capabilities=capabilities, keep_alive=True) self._is_remote = False
def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30): self.binary = firefox_binary self.profile = firefox_profile if self.profile is None: self.profile = FirefoxProfile() self.profile.native_events_enabled = self.NATIVE_EVENTS_ALLOWED and self.profile.native_events_enabled if self.binary is None: self.binary = FirefoxBinary() RemoteWebDriver.__init__( self, command_executor=ExtensionConnection("127.0.0.1", self.profile, self.binary, timeout), desired_capabilities=DesiredCapabilities.FIREFOX)
def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30, capabilities=None, proxy=None, executable_path="geckodriver", options=None, service_log_path="geckodriver.log", firefox_options=None, service_args=None, desired_capabilities=None, log_path=None, keep_alive=True): """Starts a new local session of Firefox. Based on the combination and specificity of the various keyword arguments, a capabilities dictionary will be constructed that is passed to the remote end. The keyword arguments given to this constructor are helpers to more easily allow Firefox WebDriver sessions to be customised with different options. They are mapped on to a capabilities dictionary that is passed on to the remote end. As some of the options, such as `firefox_profile` and `options.profile` are mutually exclusive, precedence is given from how specific the setting is. `capabilities` is the least specific keyword argument, followed by `options`, followed by `firefox_binary` and `firefox_profile`. In practice this means that if `firefox_profile` and `options.profile` are both set, the selected profile instance will always come from the most specific variable. In this case that would be `firefox_profile`. This will result in `options.profile` to be ignored because it is considered a less specific setting than the top-level `firefox_profile` keyword argument. Similarily, if you had specified a `capabilities["moz:firefoxOptions"]["profile"]` Base64 string, this would rank below `options.profile`. :param firefox_profile: Instance of ``FirefoxProfile`` object or a string. If undefined, a fresh profile will be created in a temporary location on the system. :param firefox_binary: Instance of ``FirefoxBinary`` or full path to the Firefox binary. If undefined, the system default Firefox installation will be used. :param timeout: Time to wait for Firefox to launch when using the extension connection. :param capabilities: Dictionary of desired capabilities. :param proxy: The proxy settings to us when communicating with Firefox via the extension connection. :param executable_path: Full path to override which geckodriver binary to use for Firefox 47.0.1 and greater, which defaults to picking up the binary from the system path. :param options: Instance of ``options.Options``. :param service_log_path: Where to log information from the driver. :param firefox_options: Deprecated argument for options :param service_args: List of args to pass to the driver service :param desired_capabilities: alias of capabilities. In future versions of this library, this will replace 'capabilities'. This will make the signature consistent with RemoteWebDriver. :param log_path: Deprecated argument for service_log_path :param keep_alive: Whether to configure remote_connection.RemoteConnection to use HTTP keep-alive. """ if log_path: warnings.warn('use service_log_path instead of log_path', DeprecationWarning, stacklevel=2) service_log_path = log_path if firefox_options: warnings.warn('use options instead of firefox_options', DeprecationWarning, stacklevel=2) options = firefox_options self.binary = None self.profile = None self.service = None # If desired capabilities is set, alias it to capabilities. # If both are set ignore desired capabilities. if capabilities is None and desired_capabilities: capabilities = desired_capabilities if capabilities is None: capabilities = DesiredCapabilities.FIREFOX.copy() if options is None: options = Options() capabilities = dict(capabilities) if capabilities.get("binary"): self.binary = capabilities["binary"] # options overrides capabilities if options is not None: if options.binary is not None: self.binary = options.binary if options.profile is not None: self.profile = options.profile # firefox_binary and firefox_profile # override options if firefox_binary is not None: if isinstance(firefox_binary, basestring): firefox_binary = FirefoxBinary(firefox_binary) self.binary = firefox_binary options.binary = firefox_binary if firefox_profile is not None: if isinstance(firefox_profile, basestring): firefox_profile = FirefoxProfile(firefox_profile) self.profile = firefox_profile options.profile = firefox_profile # W3C remote # TODO(ato): Perform conformance negotiation if capabilities.get("marionette"): capabilities.pop("marionette") self.service = Service(executable_path, service_args=service_args, log_path=service_log_path) self.service.start() capabilities.update(options.to_capabilities()) executor = FirefoxRemoteConnection( remote_server_addr=self.service.service_url) RemoteWebDriver.__init__(self, command_executor=executor, desired_capabilities=capabilities, keep_alive=True) # Selenium remote else: if self.binary is None: self.binary = FirefoxBinary() if self.profile is None: self.profile = FirefoxProfile() # disable native events if globally disabled self.profile.native_events_enabled = ( self.NATIVE_EVENTS_ALLOWED and self.profile.native_events_enabled) if proxy is not None: proxy.add_to_capabilities(capabilities) executor = ExtensionConnection("127.0.0.1", self.profile, self.binary, timeout) RemoteWebDriver.__init__(self, command_executor=executor, desired_capabilities=capabilities, keep_alive=keep_alive) self._is_remote = False