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


Python Options.set_preference方法代碼示例

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


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

示例1: test_to_capabilities

# 需要導入模塊: from selenium.webdriver.firefox.options import Options [as 別名]
# 或者: from selenium.webdriver.firefox.options.Options import set_preference [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

示例2: firefox_options

# 需要導入模塊: from selenium.webdriver.firefox.options import Options [as 別名]
# 或者: from selenium.webdriver.firefox.options.Options import set_preference [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

示例3: test_prefs

# 需要導入模塊: from selenium.webdriver.firefox.options import Options [as 別名]
# 或者: from selenium.webdriver.firefox.options.Options import set_preference [as 別名]
    def test_prefs(self):
        opts = Options()
        assert len(opts.preferences) == 0
        assert isinstance(opts.preferences, dict)

        opts.set_preference("spam", "ham")
        assert len(opts.preferences) == 1
        opts.set_preference("eggs", True)
        assert len(opts.preferences) == 2
        opts.set_preference("spam", "spam")
        assert len(opts.preferences) == 2
        assert opts.preferences == {"spam": "spam", "eggs": True}
開發者ID:juangj,項目名稱:selenium,代碼行數:14,代碼來源:mn_options_tests.py

示例4: driver_kwargs

# 需要導入模塊: from selenium.webdriver.firefox.options import Options [as 別名]
# 或者: from selenium.webdriver.firefox.options.Options import set_preference [as 別名]
def driver_kwargs(request, driver_kwargs):
    options = Options()
    options.set_preference('browser.startup.homepage_override.mstone', '')
    options.set_preference('startup.homepage_welcome_url', 'about:')
    driver_kwargs['firefox_options'] = options
    return driver_kwargs
開發者ID:Jarob22,項目名稱:selenium,代碼行數:8,代碼來源:mn_preferences_tests.py


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