Esempio n. 1
0
    def __init__(self, executable_path=None, port=0,
                 options=None, service_args=None,
                 desired_capabilities=None, service_log_path=None,
                 opera_options=None, keep_alive=True):
        """
        Creates a new instance of the operadriver.

        Starts the service and then creates new instance of operadriver.

        :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 OperaOptions
         - service_args - List of args to pass to the driver service
         - desired_capabilities: Dictionary object with non-browser specific
         - service_log_path - Where to log information from the driver.
           capabilities only, such as "proxy" or "loggingPref".
        """
        executable_path = (executable_path if executable_path is not None
                           else "operadriver")
        ChromiumDriver.__init__(self,
                                executable_path=executable_path,
                                port=port,
                                options=options,
                                service_args=service_args,
                                desired_capabilities=desired_capabilities,
                                service_log_path=service_log_path,
                                keep_alive=keep_alive)
Esempio n. 2
0
    def __init__(self, executable_path=None, port=0,
                 options=None, service_args=None,
                 desired_capabilities=None, service_log_path=None,
                 opera_options=None):
        """
        Creates a new instance of the operadriver.

        Starts the service and then creates new instance of operadriver.

        :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
        """
        if opera_options:
            warnings.warn('use options instead of opera_options', DeprecationWarning)
            options = opera_options

        executable_path = (executable_path if executable_path is not None
                           else "operadriver")
        ChromiumDriver.__init__(self,
                                executable_path=executable_path,
                                port=port,
                                options=options,
                                service_args=service_args,
                                desired_capabilities=desired_capabilities,
                                service_log_path=service_log_path)
Esempio n. 3
0
    def __init__(self, user=None, pwd=None):
        self.executable_path = r'E:\Develop\spider\software\chromedriver.exe'
        self.options = WebDriver.create_options(self)
        self.options.add_argument(
            r"user-data-dir=C:\Users\Administrator.XSOOY-20170317P\AppData\Local\Google\Chrome\User Data"
        )
        # self.options.set_headless()
        # extension_path = '/extension/path'
        # self.options.add_extension(extension_path)
        try:
            WebDriver.__init__(self,
                               executable_path=self.executable_path,
                               options=self.options)
        except Exception:
            self.quit()
            raise
        self.user = user
        self.pwd = pwd


# options = webdriver.FirefoxOptions()
# options.set_headless()
# options.add_argument('-headless')
# options.add_argument('--disable-gpu')
# firefoxProfile = webdriver.FirefoxProfile()
## Disable CSS
# firefoxProfile.set_preference('permissions.default.stylesheet', 2)
## Disable images
# firefoxProfile.set_preference('permissions.default.image', 2)
## Disable Flash
# firefoxProfile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so',  'false')
Esempio n. 4
0
    def __init__(
        self,
        executable_path: None = None,
        port=0,
        options=None,
        service_args=None,
        desired_capabilities=None,
        service_log_path=None,
        chrome_options=None,
        keep_alive=True,
    ):
        """
        Patched ChromeDriver class replaces selenium.webdriver.Chrome

        :param executable_path: do not use. it is overridden anyway
        :param port:
        :param options:
        :param service_args:
        :param desired_capabilities:
        :param service_log_path:
        :param chrome_options:
        :param keep_alive:
        """
        executable_path = _path.join(_BIN_DIR, "chrome-win32",
                                     "chromedriver.exe")

        if not options:
            options = _build_options(headless=False, verify_ssl=False)
        options.binary_location = _path.join(_BIN_DIR, "chrome-win32",
                                             "chrome.exe")

        _Chrome.__init__(
            self,
            executable_path=executable_path,
            port=port,
            options=options,
            service_args=service_args,
            desired_capabilities=desired_capabilities,
            service_log_path=service_log_path,
            chrome_options=chrome_options,
            keep_alive=keep_alive,
        )
Esempio n. 5
0
    def __init__(self,
                 executable_path=None,
                 port=0,
                 options=None,
                 service_args=None,
                 desired_capabilities=None,
                 service_log_path=None,
                 opera_options=None,
                 keep_alive=True):
        """
        Creates a new instance of the operadriver.

        Starts the service and then creates new instance of operadriver.

        :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 OperaOptions
         - service_args - List of args to pass to the driver service
         - desired_capabilities: Dictionary object with non-browser specific
         - service_log_path - Where to log information from the driver.
           capabilities only, such as "proxy" or "loggingPref".
        """
        warnings.warn(
            f"{self.__class__} is deprecated and will be removed in 4.3; "
            f"see: https://www.selenium.dev/documentation/webdriver/getting_started/open_browser/#opera",
            DeprecationWarning,
            stacklevel=2)
        executable_path = (executable_path
                           if executable_path else "operadriver")
        ChromiumDriver.__init__(self,
                                executable_path=executable_path,
                                port=port,
                                options=options,
                                service_args=service_args,
                                desired_capabilities=desired_capabilities,
                                service_log_path=service_log_path,
                                keep_alive=keep_alive)
Esempio n. 6
0
 def __init__(self):
     """ Create Chrome Driver Wrapper"""
     WebDriver.__init__(self)
     DriverWrapper.__init__(self)
Esempio n. 7
0
 def __init__(self, *args, **kwargs):
     ChromeWebDriver.__init__(self, *args, **kwargs)
     WaitUntil.__init__(self)