当前位置: 首页>>代码示例>>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;未经允许,请勿转载。