當前位置: 首頁>>代碼示例>>Python>>正文


Python Options.binary方法代碼示例

本文整理匯總了Python中selenium.webdriver.firefox.options.Options.binary方法的典型用法代碼示例。如果您正苦於以下問題:Python Options.binary方法的具體用法?Python Options.binary怎麽用?Python Options.binary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在selenium.webdriver.firefox.options.Options的用法示例。


在下文中一共展示了Options.binary方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_binary

# 需要導入模塊: from selenium.webdriver.firefox.options import Options [as 別名]
# 或者: from selenium.webdriver.firefox.options.Options import binary [as 別名]
    def test_binary(self):
        opts = Options()
        assert opts.binary is None

        other_binary = FirefoxBinary()
        assert other_binary != opts.binary
        opts.binary = other_binary
        assert other_binary == opts.binary

        path = "/path/to/binary"
        opts.binary = path
        assert isinstance(opts.binary, FirefoxBinary)
        assert opts.binary._start_cmd == path
開發者ID:juangj,項目名稱:selenium,代碼行數:15,代碼來源:mn_options_tests.py

示例2: test_to_capabilities

# 需要導入模塊: from selenium.webdriver.firefox.options import Options [as 別名]
# 或者: from selenium.webdriver.firefox.options.Options import binary [as 別名]
    def test_to_capabilities(self):
        opts = Options()
        assert opts.to_capabilities() == {}

        profile = FirefoxProfile()
        opts.profile = profile
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "profile" in caps["moz:firefoxOptions"]
        assert isinstance(caps["moz:firefoxOptions"]["profile"], basestring)
        assert caps["moz:firefoxOptions"]["profile"] == profile.encoded

        opts.add_argument("--foo")
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "args" in caps["moz:firefoxOptions"]
        assert caps["moz:firefoxOptions"]["args"] == ["--foo"]

        binary = FirefoxBinary()
        opts.binary = binary
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "binary" in caps["moz:firefoxOptions"]
        assert isinstance(caps["moz:firefoxOptions"]["binary"], basestring)
        assert caps["moz:firefoxOptions"]["binary"] == binary._start_cmd

        opts.set_preference("spam", "ham")
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "prefs" in caps["moz:firefoxOptions"]
        assert isinstance(caps["moz:firefoxOptions"]["prefs"], dict)
        assert caps["moz:firefoxOptions"]["prefs"]["spam"] == "ham"
開發者ID:juangj,項目名稱:selenium,代碼行數:34,代碼來源:mn_options_tests.py

示例3: _setup_firefox

# 需要導入模塊: from selenium.webdriver.firefox.options import Options [as 別名]
# 或者: from selenium.webdriver.firefox.options.Options import binary [as 別名]
    def _setup_firefox(self, capabilities):
        """Setup Firefox webdriver

        :param capabilities: capabilities object
        :returns: a new local Firefox driver
        """
        if capabilities.get("marionette"):
            gecko_driver = self.config.get('Driver', 'gecko_driver_path')
            self.logger.debug("Gecko driver path given in properties: %s", gecko_driver)
        else:
            gecko_driver = None

        # Get Firefox binary
        firefox_binary = self.config.get_optional('Firefox', 'binary')

        firefox_options = Options()

        if self.config.getboolean_optional('Driver', 'headless'):
            self.logger.debug("Running Firefox in headless mode")
            firefox_options.add_argument('-headless')

        self._add_firefox_arguments(firefox_options)

        if firefox_binary:
            firefox_options.binary = firefox_binary

        log_path = os.path.join(DriverWrappersPool.output_directory, 'geckodriver.log')
        try:
            # Selenium 3
            return webdriver.Firefox(firefox_profile=self._create_firefox_profile(), capabilities=capabilities,
                                     executable_path=gecko_driver, firefox_options=firefox_options, log_path=log_path)
        except TypeError:
            # Selenium 2
            return webdriver.Firefox(firefox_profile=self._create_firefox_profile(), capabilities=capabilities,
                                     executable_path=gecko_driver, firefox_options=firefox_options)
開發者ID:jframos,項目名稱:toolium,代碼行數:37,代碼來源:config_driver.py

示例4: create_instances_of_webdriver

# 需要導入模塊: from selenium.webdriver.firefox.options import Options [as 別名]
# 或者: from selenium.webdriver.firefox.options.Options import binary [as 別名]
def create_instances_of_webdriver(selenium, driver, browser_id_list, tmpdir,
                                  tmp_memory, driver_kwargs, driver_type,
                                  firefox_logging, firefox_path, xvfb,
                                  screen_width, screen_height, displays):

    for browser_id, display in zip(parse_seq(browser_id_list), cycle(xvfb)):
        if browser_id in selenium:
            raise AttributeError('{:s} already in use'.format(browser_id))
        else:
            tmp_memory[browser_id] = {'shares': {},
                                      'spaces': {},
                                      'groups': {},
                                      'mailbox': {},
                                      'oz': {},
                                      'window': {'modal': None}}

            with redirect_display(display):
                temp_dir = str(tmpdir)
                download_dir = os.path.join(temp_dir, browser_id, 'download')

                if driver_type.lower() == 'chrome':
                    options = driver_kwargs['desired_capabilities']['chromeOptions']
                    prefs = {"download.default_directory": download_dir}
                    options['prefs'].update(prefs)

                elif driver_type.lower() == 'firefox':
                    options = Options()
                    profile = FirefoxProfile()
                    log_path = _set_firefox_profile(profile, browser_id,
                                                    temp_dir, firefox_logging)
                    options.profile = profile
                    if firefox_path is not None:
                        options.binary = FirefoxBinary(firefox_path)
                    driver_kwargs['firefox_options'] = options

                browser = driver(driver_kwargs)
                if driver_type.lower() == 'firefox' and firefox_logging:
                    browser.get_log = _firefox_logger(log_path)
                _config_driver(browser, screen_width, screen_height)

            displays[browser_id] = display
            selenium[browser_id] = browser
開發者ID:indigo-dc,項目名稱:onedata,代碼行數:44,代碼來源:browser_creation.py

示例5: firefox_options

# 需要導入模塊: from selenium.webdriver.firefox.options import Options [as 別名]
# 或者: from selenium.webdriver.firefox.options.Options import binary [as 別名]
def firefox_options(request, firefox_path, firefox_profile):
    options = Options()

    if firefox_profile is not None:
        options.profile = firefox_profile

    if firefox_path is not None:
        options.binary = FirefoxBinary(firefox_path)

    args = request.node.get_marker('firefox_arguments')
    if args is not None:
        for arg in args.args:
            options.add_argument(arg)

    prefs = request.node.get_marker('firefox_preferences')
    if prefs is not None:
        for name, value in prefs.args[0].items():
            options.set_preference(name, value)

    return options
開發者ID:davehunt,項目名稱:pytest-selenium,代碼行數:22,代碼來源:firefox.py

示例6: _setup_firefox

# 需要導入模塊: from selenium.webdriver.firefox.options import Options [as 別名]
# 或者: from selenium.webdriver.firefox.options.Options import binary [as 別名]
    def _setup_firefox(self, capabilities):
        """Setup Firefox webdriver

        :param capabilities: capabilities object
        :returns: a new local Firefox driver
        """
        if capabilities.get("marionette"):
            gecko_driver = self.config.get('Driver', 'gecko_driver_path')
            self.logger.debug("Gecko driver path given in properties: {0}".format(gecko_driver))
        else:
            gecko_driver = None

        # Get Firefox binary
        firefox_binary = self.config.get_optional('Firefox', 'binary')
        if firefox_binary:
            self.logger.debug("Using firefox binary: {0}".format(firefox_binary))
            firefox_options = Options()
            firefox_options.binary = firefox_binary
        else:
            firefox_options = None

        return webdriver.Firefox(firefox_profile=self._create_firefox_profile(), capabilities=capabilities,
                                 executable_path=gecko_driver, firefox_options=firefox_options)
開發者ID:Telefonica,項目名稱:toolium,代碼行數:25,代碼來源:config_driver.py


注:本文中的selenium.webdriver.firefox.options.Options.binary方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。