def __init__(self, port=None, desired_capabilities=DesiredCapabilities.PHANTOMJS): if port is None: port = 8910 class DummyService(): """Dummy service to accept the same calls as the PhantomJS webdriver.""" def __init__(self, port): self.port = port @property def service_url(self): return 'http://localhost:%d/wd/hub' % port def stop(self, *args, **kwargs): pass self.service = DummyService(port) # Start the remote web driver. try: RemoteWebDriver.__init__(self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) except: self.quit() raise self._is_remote = False
def __init__(self, url, desired_capabilities={}): """Creates a WebDriver that controls Chrome via ChromeDriver. Args: url: The URL of a running ChromeDriver server. desired_capabilities: Requested capabilities for the new WebDriver session. """ RemoteWebDriver.__init__(self, command_executor=url, desired_capabilities=desired_capabilities) # Add custom commands. custom_commands = { WebDriver._CHROME_GET_EXTENSIONS: ('GET', '/session/$sessionId/chrome/extensions'), WebDriver._CHROME_INSTALL_EXTENSION: ('POST', '/session/$sessionId/chrome/extensions'), WebDriver._CHROME_GET_EXTENSION_INFO: ('GET', '/session/$sessionId/chrome/extension/$id'), WebDriver._CHROME_MODIFY_EXTENSION: ('POST', '/session/$sessionId/chrome/extension/$id'), WebDriver._CHROME_UNINSTALL_EXTENSION: ('DELETE', '/session/$sessionId/chrome/extension/$id'), WebDriver._CHROME_GET_VIEW_HANDLES: ('GET', '/session/$sessionId/chrome/views'), WebDriver._CHROME_DUMP_HEAP_PROFILE: ('POST', '/session/$sessionId/chrome/heapprofilerdump') } self.command_executor._commands.update(custom_commands)
def __init__(self, port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT): self.port = port if self.port == 0: self.port = utils.free_port() # Create IE Driver instance of the unmanaged code try: self.iedriver = CDLL(os.path.join(os.path.dirname(__file__),"win32", "IEDriver.dll")) except WindowsError: try: self.iedriver = CDLL(os.path.join(os.path.dirname(__file__),"x64", "IEDriver.dll")) except WindowsError: raise WebDriverException("Unable to load the IEDriver.dll component") self.ptr = self.iedriver.StartServer(self.port) seconds = 0 while not utils.is_connectable(self.port): seconds += 1 if seconds > DEFAULT_TIMEOUT: raise RuntimeError("Unable to connect to IE") time.sleep(1) RemoteWebDriver.__init__( self, command_executor='http://localhost:%d' % self.port, desired_capabilities=DesiredCapabilities.INTERNETEXPLORER)
def __init__(self, executable_path=None, port=0, desired_capabilities=DesiredCapabilities.SAFARI): """ Creates a new instance of the Safari driver. Starts the service and then creates new instance of Safari Driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the Environment Variable SELENIUM_SERVER_JAR - port - port you would like the service to run, if left as 0, a free port will be found. - desired_capabilities: Dictionary object with desired capabilities (Can be used to provide various Safari switches). """ if executable_path is None: try: executable_path = os.environ["SELENIUM_SERVER_JAR"] except: raise Exception("No executable path given, please add one to Environment Variable \ 'SELENIUM_SERVER_JAR'") self.service = Service(executable_path, port=port) self.service.start() RemoteWebDriver.__init__(self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) self._is_remote = False
def __init__(self, executable_path='IEDriverServer.exe', capabilities=None, port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT, host=DEFAULT_HOST, log_level=DEFAULT_LOG_LEVEL, log_file=DEFAULT_LOG_FILE, options=None, ie_options=None): """ Creates a new instance of the chrome driver. Starts the service and then creates new instance of chrome driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - capabilities: capabilities Dictionary object - port - port you would like the service to run, if left as 0, a free port will be found. - log_level - log level you would like the service to run. - log_file - log file you would like the service to log to. - options: IE Options instance, providing additional IE options """ if ie_options: warnings.warn('use options instead of ie_options', DeprecationWarning) options = ie_options self.port = port if self.port == 0: self.port = utils.free_port() self.host = host self.log_level = log_level self.log_file = log_file if options is None: # desired_capabilities stays as passed in if capabilities is None: capabilities = self.create_options().to_capabilities() else: if capabilities is None: capabilities = options.to_capabilities() else: capabilities.update(options.to_capabilities()) self.iedriver = Service(executable_path, port=self.port, host=self.host, log_level=self.log_level, log_file=self.log_file) self.iedriver.start() if capabilities is None: capabilities = DesiredCapabilities.INTERNETEXPLORER RemoteWebDriver.__init__(self, command_executor='http://localhost:%d' % self.port, desired_capabilities=capabilities) self._is_remote = False
def __init__(self, executable_path="phantomjs", port=0, desired_capabilities=DesiredCapabilities.PHANTOMJS, service_args=None, service_log_path=None): """ Creates a new instance of the PhantomJS / Ghostdriver. Starts the service and then creates new instance of the driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - port - port you would like the service to run, if left as 0, a free port will be found. - desired_capabilities: Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref". - service_args : A List of command line arguments to pass to PhantomJS - service_log_path: Path for phantomjs service to log to. """ warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless ' 'versions of Chrome or Firefox instead') self.service = Service( executable_path, port=port, service_args=service_args, log_path=service_log_path) self.service.start() try: RemoteWebDriver.__init__( self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) except Exception: self.quit() raise self._is_remote = False
def __init__(self, driver, browser_profile=None, proxy=None, keep_alive=False, file_detector=None, options=None): command_executor = driver.command_executor self.__driver = driver self.w3c = False self.__listeners = [] self.__listeners.append(PAFWebDriverListener()) RemoteWebDriver.__init__( self, command_executor=command_executor, desired_capabilities=driver.desired_capabilities, browser_profile=browser_profile, proxy=proxy, keep_alive=keep_alive, file_detector=file_detector, options=options) if ConfigurationsManager().contains_key( ApplicationProperties.WEBDRIVER_COMMAND_LISTENERS): class_name = ConfigurationsManager().get_str_for_key( ApplicationProperties.WEBDRIVER_COMMAND_LISTENERS) self.__listeners.append(load_class(class_name)())
def __init__(self, executable_path="phantomjs", port=0, desired_capabilities=DesiredCapabilities.PHANTOMJS, pre_command=None, service_args=None, service_log_path=None): """ Creates a new instance of the PhantomJS / Ghostdriver. Starts the service and then creates new instance of the driver. :param executable_path: path to the executable. If the default is used it assumes the executable is in the $PATH :param port: port you would like the service to run, if left as 0, a free port will be found. :param desired_capabilities: Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref". :param pre_command: Is in case the 'executable_path' has to bee called in another command. e.g.: if network namespaces are used, we need to execute phantom after 'ip netns exec <namespace_name>' :param service_args: A List of command line arguments to pass to PhantomJS :param service_log_path: Path for phantomjs service to log to. """ self.service = ServicePhantomjsExtended(executable_path, port=port, pre_command=pre_command, service_args=service_args, log_path=service_log_path) self.service.start() try: RemoteWebDriver.__init__(self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) except: self.quit() raise self._is_remote = False
def __init__(self, port=0, executable_path="/usr/bin/safaridriver", reuse_service=False, desired_capabilities=DesiredCapabilities.SAFARI, quiet=False): """ Creates a new Safari driver instance and launches or finds a running safaridriver service. :Args: - port - The port on which the safaridriver service should listen for new connections. If zero, a free port will be found. - quiet - If True, the driver's stdout and stderr is suppressed. - executable_path - Path to a custom safaridriver executable to be used. If absent, /usr/bin/safaridriver is used. - desired_capabilities: Dictionary object with desired capabilities (Can be used to provide various Safari switches). - reuse_service - If True, do not spawn a safaridriver instance; instead, connect to an already-running service that was launched externally. """ self._reuse_service = reuse_service self.service = Service(executable_path, port=port, quiet=quiet) if not reuse_service: self.service.start() executor = SafariRemoteConnection(remote_server_addr=self.service.service_url) RemoteWebDriver.__init__( self, command_executor=executor, desired_capabilities=desired_capabilities) self._is_remote = False
def __init__(self, executable_path='MicrosoftWebDriver.exe', capabilities=None, port=0, verbose=False, log_path=None): self.port = port if self.port == 0: self.port = utils.free_port() self.edge_service = Service(executable_path, port=self.port, verbose=verbose, log_path=log_path) self.edge_service.start() if capabilities is None: capabilities = DesiredCapabilities.EDGE RemoteWebDriver.__init__(self, command_executor=RemoteConnection( 'http://localhost:%d' % self.port, resolve_ip=False), desired_capabilities=capabilities) self._is_remote = False
def __init__(self, executable_path='IEDriverServer.exe', capabilities=None, port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT, host=DEFAULT_HOST, log_level=DEFAULT_LOG_LEVEL, log_file=DEFAULT_LOG_FILE): self.port = port if self.port == 0: self.port = utils.free_port() self.host = host self.log_level = log_level self.log_file = log_file self.iedriver = Service( executable_path, port=self.port, host=self.host, log_level=self.log_level, log_file=self.log_file) self.iedriver.start() if capabilities is None: capabilities = DesiredCapabilities.INTERNETEXPLORER RemoteWebDriver.__init__( self, command_executor='http://localhost:%d' % self.port, desired_capabilities=capabilities) self._is_remote = False
def __init__(self, port=0, executable_path="/usr/bin/safaridriver", reuse_service=False, desired_capabilities=DesiredCapabilities.SAFARI, quiet=False, keep_alive=True, service_args=None): """ Creates a new Safari drive instance and launches or finds a running safaridriver service. :Args: - port - The port on which the safaridriver service should listen for new connections. If zero, a free port will be found. - executable_path - Path to a custom safaridriver executable to be used. If absent, /usr/bin/safaridriver is used. - reuse_service - If True, do not spawn a safaridriver instance; instead, connect to an already-running service that was launched externally. - desired_capabilities: Dictionary object with desired capabilities (Can be used to provide various Safari switches). - quiet - If True, the drive's stdout and stderr is suppressed. - keep_alive - Whether to configure SafariRemoteConnection to use HTTP keep-alive. Defaults to False. - service_args : List of args to pass to the safaridriver service """ self._reuse_service = reuse_service self.service = Service(executable_path, port=port, quiet=quiet, service_args=service_args) if not reuse_service: self.service.start() executor = SafariRemoteConnection(remote_server_addr=self.service.service_url, keep_alive=keep_alive) RemoteWebDriver.__init__( self, command_executor=executor, desired_capabilities=desired_capabilities) self._is_remote = False
def __init__(self, executable_path=os.environ['OPENSHIFT_REPO_DIR']+"PhantomJSpatched/phantomjs", ip='127.0.0.1', port=0, desired_capabilities=DesiredCapabilities.PHANTOMJS, service_args=None, service_log_path=None): """ Creates a new instance of the PhantomJS / Ghostdriver. Starts the service and then creates new instance of the driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - port - port you would like the service to run, if left as 0, a free port will be found. - desired_capabilities: Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref". - service_args : A List of command line arguments to pass to PhantomJS - service_log_path: Path for phantomjs service to log to. """ self.service = Service(executable_path,ip=ip, port=port, service_args=service_args, log_path=service_log_path) self.service.start() try: RemoteWebDriver.__init__(self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) except: self.quit() raise self._is_remote = False
def __init__(self, executable_path='IEDriverServer.exe', port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT): self.port = port if self.port == 0: self.port = utils.free_port() try: self.iedriver = Service(executable_path, port=self.port) self.iedriver.start() except: # Create IE Driver instance of the unmanaged code try: warnings.warn("You need to download the IEDriverServer. \ Using the deprecated approach", DeprecationWarning) self.iedriver = CDLL(os.path.join(os.path.dirname(__file__),"win32", "IEDriver.dll")) except WindowsError: try: self.iedriver = CDLL(os.path.join(os.path.dirname(__file__),"x64", "IEDriver.dll")) except WindowsError: raise WebDriverException("Unable to load the IEDriver.dll component") self.ptr = self.iedriver.StartServer(self.port) seconds = 0 while not utils.is_url_connectable(self.port): seconds += 1 if seconds > DEFAULT_TIMEOUT: # Clean up after ourselves self.quit() raise RuntimeError("Unable to connect to IE") time.sleep(1) RemoteWebDriver.__init__( self, command_executor='http://localhost:%d' % self.port, desired_capabilities=DesiredCapabilities.INTERNETEXPLORER)
def __init__(self, executable_path="chromedriver", port=0, chrome_options=None, service_args=None, desired_capabilities=None): """ Creates a new instance of the chrome driver. Starts the service and then creates new instance of chrome driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - port - port you would like the service to run, if left as 0, a free port will be found. - desired_capabilities: Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref". - chrome_options: this takes an instance of ChromeOptions """ if chrome_options is None: options = Options() else: options = chrome_options if desired_capabilities is not None: desired_capabilities.update(options.to_capabilities()) else: desired_capabilities = options.to_capabilities() self.service = Service(executable_path, port=port, service_args=service_args) self.service.start() try: RemoteWebDriver.__init__(self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) except: self.quit() raise
def __init__(self, port=0, executable_path="/usr/bin/safaridriver", reuse_service=False, desired_capabilities=DesiredCapabilities.SAFARI, quiet=False): """ Creates a new Safari driver instance and launches or finds a running safaridriver service. :Args: - port - The port on which the safaridriver service should listen for new connections. If zero, a free port will be found. - quiet - If True, the driver's stdout and stderr is suppressed. - executable_path - Path to a custom safaridriver executable to be used. If absent, /usr/bin/safaridriver is used. - desired_capabilities: Dictionary object with desired capabilities (Can be used to provide various Safari switches). - reuse_service - If True, do not spawn a safaridriver instance; instead, connect to an already-running service that was launched externally. """ self._reuse_service = reuse_service if not reuse_service: self.service.start() RemoteWebDriver.__init__(self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) self._is_remote = False
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, executable_path="phantomjs", port=0, desired_capabilities=DesiredCapabilities.PHANTOMJS, service_args=None, service_log_path=None): """ Creates a new instance of the PhantomJS / Ghostdriver. Starts the service and then creates new instance of the driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - port - port you would like the service to run, if left as 0, a free port will be found. - desired_capabilities: Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref". - service_args : A List of command line arguments to pass to PhantomJS - service_log_path: Path for phantomjs service to log to. """ self.service = Service(executable_path, port=port, service_args=service_args, log_path=service_log_path) self.service.start() command_executor = self.service.service_url try: RemoteWebDriver.__init__(self, command_executor=command_executor, desired_capabilities=desired_capabilities) except: self.quit() raise self._is_remote = False # Patch to support Native PhantomJS script self.command_executor = RemoteConnection(command_executor, keep_alive=False) Command.EXECUTE_PHANTOM_SCRIPT = "executePhantomScript" self.command_executor._commands[Command.EXECUTE_PHANTOM_SCRIPT] = ("POST", "/session/$sessionId/phantom/execute")
def __init__(self, executable_path=None, port=0, desired_capabilities=DesiredCapabilities.SAFARI, quiet=False, use_legacy_driver=False): """ Creates a new instance of the Safari driver. Starts the service and then creates new instance of Safari Driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the Environment Variable SELENIUM_SERVER_JAR - port - port you would like the service to run, if left as 0, a free port will be found. - desired_capabilities: Dictionary object with desired capabilities (Can be used to provide various Safari switches). """ if not executable_path is None: executable_path = os.environ.get("SELENIUM_SERVER_JAR") self.service = Service(executable_path, port=port, quiet=quiet, use_legacy=use_legacy_driver) self.service.start() RemoteWebDriver.__init__(self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) self._is_remote = False
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, keep_alive=True) self._is_remote = False
def __init__(self, executable_path="phantomjs", port=0, desired_capabilities=DesiredCapabilities.PHANTOMJS, pre_command=None, service_args=None, service_log_path=None): """ Creates a new instance of the PhantomJS / Ghostdriver. Starts the service and then creates new instance of the driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - port - port you would like the service to run, if left as 0, a free port will be found. - desired_capabilities: Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref". - pre_command : Is in case the 'executable_path' has to bee called in another command. e.g.: if network namespaces are used, we need to execute phantom after 'ip netns exec <namespace_name>' - service_args : A List of command line arguments to pass to PhantomJS - service_log_path: Path for phantomjs service to log to. """ self.service = ServicePhantomjsExtended(executable_path, port=port, pre_command=pre_command, service_args=service_args, log_path=service_log_path) self.service.start() try: RemoteWebDriver.__init__(self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) except: self.quit() raise self._is_remote = False
def __init__(self, device_password, bb_tools_dir=None, hostip='169.254.0.1', port=1338, desired_capabilities={}): import warnings warnings.warn('BlackBerry Driver is no longer supported and will be ' 'removed in future versions', DeprecationWarning, stacklevel=2) remote_addr = 'http://{}:{}'.format(hostip, port) filename = 'blackberry-deploy' if platform.system() == "Windows": filename += '.bat' if bb_tools_dir is not None: if os.path.isdir(bb_tools_dir): bb_deploy_location = os.path.join(bb_tools_dir, filename) if not os.path.isfile(bb_deploy_location): raise WebDriverException('Invalid blackberry-deploy location: {}'.format(bb_deploy_location)) else: raise WebDriverException('Invalid blackberry tools location, must be a directory: {}'.format(bb_tools_dir)) else: bb_deploy_location = filename """ Now launch the BlackBerry browser before allowing anything else to run. """ try: launch_args = [bb_deploy_location, '-launchApp', str(hostip), '-package-name', 'sys.browser', '-package-id', 'gYABgJYFHAzbeFMPCCpYWBtHAm0', '-password', str(device_password)] with open(os.devnull, 'w') as fp: p = subprocess.Popen(launch_args, stdout=fp) returncode = p.wait() if returncode == 0: # wait for the BlackBerry10 browser to load. is_running_args = [bb_deploy_location, '-isAppRunning', str(hostip), '-package-name', 'sys.browser', '-package-id', 'gYABgJYFHAzbeFMPCCpYWBtHAm0', '-password', str(device_password)] WebDriverWait(None, LOAD_TIMEOUT)\ .until(lambda x: subprocess.check_output(is_running_args) .find('result::true'), message='waiting for BlackBerry10 browser to load') RemoteWebDriver.__init__(self, command_executor=remote_addr, desired_capabilities=desired_capabilities) else: raise WebDriverException('blackberry-deploy failed to launch browser') except Exception as e: raise WebDriverException('Something went wrong launching blackberry-deploy', stacktrace=getattr(e, 'stacktrace', None))
def __init__(self, executable_path='IEDriverServer.exe', port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT, host=DEFAULT_HOST, log_level=DEFAULT_LOG_LEVEL, log_file=DEFAULT_LOG_FILE): self.port = port if self.port == 0: self.port = utils.free_port() self.host = host self.log_level = log_level self.log_file = log_file self.iedriver = Service(executable_path, port=self.port, host=self.host, log_level=self.log_level, log_file=self.log_file) self.iedriver.start() RemoteWebDriver.__init__( self, command_executor='http://localhost:%d' % self.port, desired_capabilities=DesiredCapabilities.INTERNETEXPLORER) self._is_remote = False
def __init__(self, port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT): self.port = port if self.port == 0: self.port = utils.free_port() # Create IE Driver instance of the unmanaged code try: self.iedriver = CDLL( os.path.join(os.path.dirname(__file__), "win32", "IEDriver.dll")) except WindowsError: try: self.iedriver = CDLL( os.path.join(os.path.dirname(__file__), "x64", "IEDriver.dll")) except WindowsError: raise WebDriverException( "Unable to load the IEDriver.dll component") self.ptr = self.iedriver.StartServer(self.port) seconds = 0 while not utils.is_connectable(self.port): seconds += 1 if seconds > DEFAULT_TIMEOUT: raise RuntimeError("Unable to connect to IE") time.sleep(1) RemoteWebDriver.__init__( self, command_executor='http://localhost:%d' % self.port, desired_capabilities=DesiredCapabilities.INTERNETEXPLORER)
def __init__(self, executable_path="WebKitWebDriver", port=0, options=None, desired_capabilities=DesiredCapabilities.WEBKITGTK, service_log_path=None): """ Creates a new instance of the WebKitGTK driver. Starts the service and then creates new instance of WebKitGTK Driver. :Args: - executable_path : path to the executable. If the default is used it assumes the executable is in the $PATH. - port : port you would like the service to run, if left as 0, a free port will be found. - options : an instance of WebKitGTKOptions - desired_capabilities : Dictionary object with desired capabilities - service_log_path : Path to write service stdout and stderr output. """ if options is not None: capabilities = options.to_capabilities() capabilities.update(desired_capabilities) desired_capabilities = capabilities self.service = Service(executable_path, port=port, log_path=service_log_path) self.service.start() RemoteWebDriver.__init__( self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) self._is_remote = False
def __init__(self, executable_path="WebKitWebDriver", port=0, options=None, desired_capabilities=DesiredCapabilities.WEBKITGTK, service_log_path=None, keep_alive=False): """ Creates a new instance of the WebKitGTK driver. Starts the service and then creates new instance of WebKitGTK Driver. :Args: - executable_path : path to the executable. If the default is used it assumes the executable is in the $PATH. - port : port you would like the service to run, if left as 0, a free port will be found. - options : an instance of WebKitGTKOptions - desired_capabilities : Dictionary object with desired capabilities - service_log_path : Path to write service stdout and stderr output. - keep_alive : Whether to configure RemoteConnection to use HTTP keep-alive. """ if options is not None: capabilities = options.to_capabilities() capabilities.update(desired_capabilities) desired_capabilities = capabilities self.service = Service(executable_path, port=port, log_path=service_log_path) self.service.start() RemoteWebDriver.__init__( self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities, keep_alive=keep_alive) self._is_remote = False
def __init__(self, deviceID=None, port=0): self.service = Service(deviceID, port=port) self.service.start() RemoteWebDriver.__init__( self, command_executor=self.service.service_url, desired_capabilities=DesiredCapabilities.ANDROID)
def __init__(self, params=None, firefox_profile=None, firefox_binary=None, timeout=30): self.binary = firefox_binary self.profile = firefox_profile if self.profile is None: self.profile = FirefoxProfile() if self.binary is None: self.binary = FirefoxBinary() COMMAND_EXECUTOR = ExtensionConnection if type(COMMAND_EXECUTOR) == str: cmd_executor = COMMAND_EXECUTOR else: cmd_executor = COMMAND_EXECUTOR( "127.0.0.1", self.profile, self.binary, timeout ) RemoteWebDriver.__init__(self, command_executor=cmd_executor, desired_capabilities=DesiredCapabilities.FIREFOX)
def __init__(self, executable_path="phantomjs", port=0, desired_capabilities=DesiredCapabilities.PHANTOMJS, service_args=None, service_log_path=None): """ Creates a new instance of the PhantomJS / Ghostdriver. Starts the service and then creates new instance of the driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - port - port you would like the service to run, if left as 0, a free port will be found. - desired_capabilities: Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref". - service_args : A List of command line arguments to pass to PhantomJS - service_log_path: Path for phantomjs service to log to. """ self.service = Service(executable_path, port=port, service_args=service_args, log_path=service_log_path) self.service.start() try: RemoteWebDriver.__init__(self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) except: self.quit() raise self._is_remote = False
def __init__(self, ghostdriver_path, executable_path="phantomjs", port=0, desired_capabilities=DesiredCapabilities.PHANTOMJS): """ Creates a new instance of the PhantomJS / Ghostdriver. Starts the service and then creates new instance of the driver. :Args: - ghostdriver_path - path to ghostdriver/src/main.js - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - port - port you would like the service to run, if left as 0, a free port will be found. - desired_capabilities: Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref". """ self.service = Service(executable_path, ghostdriver_path, port=port) self.service.start() try: RemoteWebDriver.__init__(self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) except: self.quit() raise
def __init__(self, executable_path="chromedriver", port=0, desired_capabilities=None, chrome_options=None): """ Creates a new instance of the chrome driver. Starts the service and then creates new instance of chrome driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - port - port you would like the service to run, if left as 0, a free port will be found. - desired_capabilities: Dictionary object with desired capabilities (Can be used to provide various chrome switches). This is being deprecated, please use chrome_options - chrome_options: this takes an instance of ChromeOptions """ if chrome_options is None: options = Options() else: options = chrome_options if desired_capabilities is not None: warnings.warn("Desired Capabilities has been deprecated, please user chrome_options.", DeprecationWarning) desired_capabilities.update(options.to_capabilities()) else: desired_capabilities = options.to_capabilities() self.service = Service(executable_path, port=port) self.service.start() try: RemoteWebDriver.__init__(self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) except: self.quit() raise WebDriverException("The Driver was not able to start.")
def __init__(self, executable_path="phantomjs", port=0, desired_capabilities=DesiredCapabilities.PHANTOMJS): """ Creates a new instance of the PhantomJS / Ghostdriver. Starts the service and then creates new instance of the driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - port - port you would like the service to run, if left as 0, a free port will be found. - desired_capabilities: Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref". """ self.service = Service(executable_path, port=port) self.service.start() try: RemoteWebDriver.__init__(self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) except: self.quit() raise self._is_remote = False
def __init__(self, executable_path="chromedriver", port=0, use_mobile_emulation=False, options=None, service_args=None, desired_capabilities=None, service_log_path=None, chrome_options=None): self.use_mobile_emulation = use_mobile_emulation """ Creates a new instance of the violent chrome driver. Starts the service and then creates new instance of chrome driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - port - port you would like the service to run, if left as 0, a free port will be found. - desired_capabilities: Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref". - options: this takes an instance of ChromeOptions - use_mobile_emulation: whether use mobile emulation or not , default is False """ if self.use_mobile_emulation: mobile_emulation = { "deviceMetrics": {"width": 360, "height": 640, "pixelRatio": 3.0}, "userAgent": "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19"} chrome_options = Options() chrome_options.add_argument('disable-infobars') chrome_options.add_experimental_option("mobileEmulation", mobile_emulation) if chrome_options: warnings.warn('use options instead of chrome_options', DeprecationWarning) options = chrome_options if options is None: # desired_capabilities stays as passed in if desired_capabilities is None: desired_capabilities = self.create_options().to_capabilities() else: if desired_capabilities is None: desired_capabilities = options.to_capabilities() else: desired_capabilities.update(options.to_capabilities()) self.service = Service( executable_path, port=port, service_args=service_args, log_path=service_log_path) self.service.start() try: RemoteWebDriver.__init__( self, command_executor=ChromeRemoteConnection( remote_server_addr=self.service.service_url), desired_capabilities=desired_capabilities) except Exception: self.quit() raise self._is_remote = False
def __init__(self, executable_path="chromedriver", port=0, options=None, service_args=None, desired_capabilities=None, service_log_path=None, chrome_options=None, keep_alive=True): """ Creates a new instance of the chrome driver. Starts the service and then creates new instance of chrome driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - port - port you would like the service to run, if left as 0, a free port will be found. - options - this takes an instance of ChromeOptions - service_args - List of args to pass to the driver service - desired_capabilities - Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref". - service_log_path - Where to log information from the driver. - chrome_options - Deprecated argument for options - keep_alive - Whether to configure ChromeRemoteConnection to use HTTP keep-alive. """ if chrome_options: warnings.warn('use options instead of chrome_options', DeprecationWarning, stacklevel=2) options = chrome_options if options is None: # desired_capabilities stays as passed in if desired_capabilities is None: desired_capabilities = self.create_options().to_capabilities() else: if desired_capabilities is None: desired_capabilities = options.to_capabilities() else: desired_capabilities.update(options.to_capabilities()) self.service = Service(executable_path, port=port, service_args=service_args, log_path=service_log_path) self.service.start() try: RemoteWebDriver.__init__( self, command_executor=ChromeRemoteConnection( remote_server_addr=self.service.service_url, keep_alive=keep_alive), desired_capabilities=desired_capabilities) except Exception: self.quit() raise self._is_remote = False
def __init__(self, device_password, bb_tools_dir=None, hostip='169.254.0.1', port=1338, desired_capabilities={}): remote_addr = 'http://{}:{}'.format(hostip, port) filename = 'blackberry-deploy' if platform.system() == "Windows": filename += '.bat' if bb_tools_dir is not None: if os.path.isdir(bb_tools_dir): bb_deploy_location = os.path.join(bb_tools_dir, filename) if not os.path.isfile(bb_deploy_location): raise WebDriverException('Invalid blackberry-deploy location: {}'.format(bb_deploy_location)) else: raise WebDriverException( 'Invalid blackberry tools location, must be a directory: {}'.format(bb_tools_dir)) else: bb_deploy_location = filename """ Now launch the BlackBerry browser before allowing anything else to run. """ try: launch_args = [bb_deploy_location, '-launchApp', str(hostip), '-package-name', 'sys.browser', '-package-id', 'gYABgJYFHAzbeFMPCCpYWBtHAm0', '-password', str(device_password)] with open(os.devnull, 'w') as fp: p = subprocess.Popen(launch_args, stdout=fp) returncode = p.wait() if returncode == 0: # wait for the BlackBerry10 browser to load. is_running_args = [bb_deploy_location, '-isAppRunning', str(hostip), '-package-name', 'sys.browser', '-package-id', 'gYABgJYFHAzbeFMPCCpYWBtHAm0', '-password', str(device_password)] WebDriverWait(None, LOAD_TIMEOUT) \ .until(lambda x: subprocess.check_output(is_running_args) .find('result::true'), message='waiting for BlackBerry10 browser to load') RemoteWebDriver.__init__(self, command_executor=remote_addr, desired_capabilities=desired_capabilities) else: raise WebDriverException('blackberry-deploy failed to launch browser') except Exception as e: raise WebDriverException('Something went wrong launching blackberry-deploy', stacktrace=getattr(e, 'stacktrace', None))
def __init__(self, executable_path='IEDriverServer.exe', capabilities=None, port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT, host=DEFAULT_HOST, log_level=DEFAULT_LOG_LEVEL, service_log_path=DEFAULT_SERVICE_LOG_PATH, options=None, ie_options=None, desired_capabilities=None, log_file=None): """ Creates a new instance of the chrome driver. Starts the service and then creates new instance of chrome driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - capabilities: capabilities Dictionary object - port - port you would like the service to run, if left as 0, a free port will be found. - log_level - log level you would like the service to run. - service_log_path - target of logging of service, may be "stdout", "stderr" or file path. - options: IE Options instance, providing additional IE options - desired_capabilities: alias of capabilities; this will make the signature consistent with RemoteWebDriver. """ if log_file: warnings.warn('use service_log_path instead of log_file', DeprecationWarning) service_log_path = log_file if ie_options: warnings.warn('use options instead of ie_options', DeprecationWarning) options = ie_options self.port = port if self.port == 0: self.port = utils.free_port() self.host = host # If both capabilities and desired capabilities are set, ignore desired capabilities. if capabilities is None and desired_capabilities: capabilities = desired_capabilities if options is None: if capabilities is None: capabilities = self.create_options().to_capabilities() else: if capabilities is None: capabilities = options.to_capabilities() else: # desired_capabilities stays as passed in capabilities.update(options.to_capabilities()) self.iedriver = Service( executable_path, port=self.port, host=self.host, log_level=log_level, log_file=service_log_path) self.iedriver.start() RemoteWebDriver.__init__( self, command_executor='http://localhost:%d' % self.port, desired_capabilities=capabilities) self._is_remote = False
def __init__( self, capabilities: dict, token: str, projectname: str, jobname: str, disable_reports: bool, ): if BaseDriver.__instance is not None: raise SdkException("A driver session already exists") LoggingHelper.configure_logging() if token is not None: logging.info(f"Token used as specified in constructor: {token}") self._token = token if token is not None else ConfigHelper.get_developer_token( ) if disable_reports: # Setting the project and job name to empty strings will cause the Agent to not initialize a report self._projectname = "" self._jobname = "" else: self._projectname = (projectname if projectname is not None else ReportHelper.infer_project_name()) self._jobname = (jobname if jobname is not None else ReportHelper.infer_job_name()) self._agent_client: AgentClient = AgentClient( token=self._token, capabilities=capabilities, reportsettings=ReportSettings(self._projectname, self._jobname), ) self._agent_session: AgentSession = self._agent_client.agent_session self.w3c = True if self._agent_session.dialect == "W3C" else False # Create a custom command executor to enable: # - automatic logging capabilities # - customized reporting settings self.command_executor = CustomCommandExecutor( agent_client=self._agent_client, remote_server_addr=self._agent_session.remote_address, ) self.command_executor.disable_reports = disable_reports RemoteWebDriver.__init__( self, command_executor=self.command_executor, desired_capabilities=self._agent_session.capabilities, ) BaseDriver.__instance = self
def __init__(self, executable_path='IEDriverServer.exe', capabilities=None, port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT, host=DEFAULT_HOST, log_level=DEFAULT_LOG_LEVEL, log_file=DEFAULT_LOG_FILE, options=None, ie_options=None): """ Creates a new instance of the chrome driver. Starts the service and then creates new instance of chrome driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - capabilities: capabilities Dictionary object - port - port you would like the service to run, if left as 0, a free port will be found. - log_level - log level you would like the service to run. - log_file - log file you would like the service to log to. - options: IE Options instance, providing additional IE options """ if ie_options: warnings.warn('use options instead of ie_options', DeprecationWarning) options = ie_options self.port = port if self.port == 0: self.port = utils.free_port() self.host = host self.log_level = log_level self.log_file = log_file if options is None: # desired_capabilities stays as passed in if capabilities is None: capabilities = self.create_options().to_capabilities() else: if capabilities is None: capabilities = options.to_capabilities() else: capabilities.update(options.to_capabilities()) self.iedriver = Service( executable_path, port=self.port, host=self.host, log_level=self.log_level, log_file=self.log_file) self.iedriver.start() if capabilities is None: capabilities = DesiredCapabilities.INTERNETEXPLORER RemoteWebDriver.__init__( self, command_executor='http://localhost:%d' % self.port, desired_capabilities=capabilities) self._is_remote = False
def __init__(self, executable_path='MicrosoftWebDriver.exe', capabilities=None, port=DEFAULT_PORT, verbose=False, service_log_path=None, log_path=DEFAULT_SERVICE_LOG_PATH, service=None, options=None, keep_alive=False): """ Creates a new instance of the chrome driver. Starts the service and then creates new instance of chrome driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - capabilities - Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref". - port - port you would like the service to run, if left as 0, a free port will be found. - verbose - whether to set verbose logging in the service - service_log_path - Where to log information from the driver. - keep_alive - Whether to configure EdgeRemoteConnection to use HTTP keep-alive. """ if port != DEFAULT_PORT: warnings.warn('port has been deprecated, please pass in a Service object', DeprecationWarning, stacklevel=2) self.port = port if service_log_path != DEFAULT_SERVICE_LOG_PATH: warnings.warn('service_log_path has been deprecated, please pass in a Service object', DeprecationWarning, stacklevel=2) if capabilities is not None: warnings.warn('capabilities has been deprecated, please pass in a Service object', DeprecationWarning, stacklevel=2) if service_log_path != DEFAULT_SERVICE_LOG_PATH: warnings.warn('service_log_path has been deprecated, please pass in a Service object', DeprecationWarning, stacklevel=2) if verbose: warnings.warn('verbose has been deprecated, please pass in a Service object', DeprecationWarning, stacklevel=2) if service: self.edge_service = service else: self.edge_service = Service(executable_path, port=self.port, verbose=verbose, log_path=service_log_path) self.edge_service.start() if capabilities is None: capabilities = DesiredCapabilities.EDGE RemoteWebDriver.__init__( self, command_executor=RemoteConnection(self.service.service_url, resolve_ip=False, keep_alive=keep_alive), desired_capabilities=capabilities) self._is_remote = False
def __init__(self, executable_path="chromedriver", port=0, options=None, service_args=None, desired_capabilities=None, service_log_path=None, chrome_options=None, keep_alive=True): """ Creates a new instance of the chrome driver. Starts the service and then creates new instance of chrome driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - port - port you would like the service to run, if left as 0, a free port will be found. - options - this takes an instance of ChromeOptions - service_args - List of args to pass to the driver service - desired_capabilities - Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref". - service_log_path - Where to log information from the driver. - chrome_options - Deprecated argument for options - keep_alive - Whether to configure ChromeRemoteConnection to use HTTP keep-alive. """ if chrome_options: warnings.warn('use options instead of chrome_options', DeprecationWarning, stacklevel=2) options = chrome_options if options is None: # desired_capabilities stays as passed in if desired_capabilities is None: desired_capabilities = self.create_options().to_capabilities() else: if desired_capabilities is None: desired_capabilities = options.to_capabilities() else: desired_capabilities.update(options.to_capabilities()) self.service = Service( executable_path, port=port, service_args=service_args, log_path=service_log_path) self.service.start() try: RemoteWebDriver.__init__( self, command_executor=ChromeRemoteConnection( remote_server_addr=self.service.service_url, keep_alive=keep_alive), desired_capabilities=desired_capabilities) except Exception: self.quit() raise self._is_remote = False
def __init__(self, executable_path='IEDriverServer.exe', capabilities=None, port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT, host=DEFAULT_HOST, log_level=DEFAULT_LOG_LEVEL, service_log_path=DEFAULT_SERVICE_LOG_PATH, options=None, ie_options=None, desired_capabilities=None, log_file=None, keep_alive=False): """ Creates a new instance of the chrome driver. Starts the service and then creates new instance of chrome driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - capabilities: capabilities Dictionary object - port - port you would like the service to run, if left as 0, a free port will be found. - timeout - no longer used, kept for backward compatibility - host - IP address for the service - log_level - log level you would like the service to run. - service_log_path - target of logging of service, may be "stdout", "stderr" or file path. - options - IE Options instance, providing additional IE options - desired_capabilities - alias of capabilities; this will make the signature consistent with RemoteWebDriver. - keep_alive - Whether to configure RemoteConnection to use HTTP keep-alive. """ self.port = port self.host = host # If both capabilities and desired capabilities are set, ignore desired capabilities. if capabilities is None and desired_capabilities: capabilities = desired_capabilities if options is None: if capabilities is None: capabilities = self.create_options().to_capabilities() else: if capabilities is None: capabilities = options.to_capabilities() else: # desired_capabilities stays as passed in capabilities.update(options.to_capabilities()) self.iedriver = Service( executable_path, port=self.port, host=self.host, log_level=log_level, log_file=service_log_path) self.iedriver.start() RemoteWebDriver.__init__( self, command_executor='http://localhost:%d' % self.port, desired_capabilities=capabilities, keep_alive=keep_alive) self._is_remote = False
def __init__(self, host="localhost", port=4444, desired_capabilities=DesiredCapabilities.ANDROID): """ Creates a new instance of Selendroid using the WebView app :Args: - host - location of where selendroid is running - port - port that selendroid is running on - desired_capabilities: Dictionary object with capabilities """ RemoteWebDriver.__init__(self, command_executor="http://%s:%d/wd/hub" % (host, port), desired_capabilities=desired_capabilities)
def __init__(self, executable_path='IEDriverServer.exe', port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT): self.port = port if self.port == 0: self.port = utils.free_port() self.iedriver = Service(executable_path, port=self.port) self.iedriver.start() RemoteWebDriver.__init__( self, command_executor='http://localhost:%d' % self.port, desired_capabilities=DesiredCapabilities.INTERNETEXPLORER)
def __init__(self, host="localhost", port=4444, desired_capabilities=DesiredCapabilities.ANDROID): """ Creates a new instance of Selendroid using the WebView app :Args: - host - location of where selendroid is running - port - port that selendroid is running on - desired_capabilities: Dictionary object with capabilities """ RemoteWebDriver.__init__( self, command_executor="http://%s:%d/wd/hub" % (host, port), desired_capabilities=desired_capabilities)
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, executable_path='MicrosoftWebDriver.exe', capabilities=None, port=0, verbose=False, service_log_path=None, log_path=None, keep_alive=False): """ Creates a new instance of the chrome driver. Starts the service and then creates new instance of chrome driver. :Args: - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH - capabilities - Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref". - port - port you would like the service to run, if left as 0, a free port will be found. - verbose - whether to set verbose logging in the service - service_log_path - Where to log information from the driver. - log_path: Deprecated argument for service_log_path - keep_alive - Whether to configure ChromeRemoteConnection 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 self.port = port if self.port == 0: self.port = utils.free_port() self.edge_service = Service(executable_path, port=self.port, verbose=verbose, log_path=service_log_path) self.edge_service.start() if capabilities is None: capabilities = DesiredCapabilities.EDGE RemoteWebDriver.__init__(self, command_executor=RemoteConnection( 'http://localhost:%d' % self.port, resolve_ip=False, keep_alive=keep_alive), desired_capabilities=capabilities) 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, executable_path='MicrosoftWebDriver.exe', desired_capabilities=DesiredCapabilities.EDGE, port=0): self.port = port if self.port == 0: self.port = utils.free_port() self.edge_service = Service(executable_path, port=self.port) self.edge_service.start() RemoteWebDriver.__init__( self, command_executor=RemoteConnection('http://localhost:%d' % self.port, resolve_ip=False), desired_capabilities=desired_capabilities) 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() 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, executable_path="chromedriver", port=0): """ Creates a new instance of the chrome driver. Starts the service and then creates Attributes: executable_path : path to the executable. If the default is used it assumes the executable is in the $PATH port : port you would like the service to run, if left as 0, a free port will be found """ self.service = Service(executable_path, port=port) self.service.start() RemoteWebDriver.__init__(self, command_executor=self.service.service_url, desired_capabilities=DesiredCapabilities.CHROME)
def __init__(self, executable_path='MicrosoftWebDriver.exe', capabilities=None, port=0): self.port = port if self.port == 0: self.port = utils.free_port() self.edge_service = Service(executable_path, port=self.port) self.edge_service.start() if capabilities is None: capabilities = DesiredCapabilities.EDGE RemoteWebDriver.__init__( self, command_executor='http://localhost:%d' % self.port, 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 self.binary is None: self.binary = capabilities.get("binary") or FirefoxBinary() # marionette if capabilities.get("marionette"): if isinstance(self.binary, FirefoxBinary): self.binary = self.binary._get_firefox_start_cmd() 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) 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