本文整理汇总了Python中selenium.webdriver.FirefoxProfile.set_proxy方法的典型用法代码示例。如果您正苦于以下问题:Python FirefoxProfile.set_proxy方法的具体用法?Python FirefoxProfile.set_proxy怎么用?Python FirefoxProfile.set_proxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.FirefoxProfile
的用法示例。
在下文中一共展示了FirefoxProfile.set_proxy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_autodetect_proxy_is_set_in_profile
# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import set_proxy [as 别名]
def test_autodetect_proxy_is_set_in_profile():
profile = FirefoxProfile()
proxy = Proxy()
proxy.auto_detect = True
profile.set_proxy(proxy)
assert profile.default_preferences["network.proxy.type"] == ProxyType.AUTODETECT['ff_value']
示例2: test_pac_proxy_is_set_in_profile
# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import set_proxy [as 别名]
def test_pac_proxy_is_set_in_profile():
profile = FirefoxProfile()
proxy = Proxy()
proxy.proxy_autoconfig_url = 'http://some.url:12345/path'
profile.set_proxy(proxy)
assert profile.default_preferences["network.proxy.type"] == ProxyType.PAC['ff_value']
assert profile.default_preferences["network.proxy.autoconfig_url"] == 'http://some.url:12345/path'
示例3: start_firefox
# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import set_proxy [as 别名]
def start_firefox(proxy=None, user_agent=None):
p = FirefoxProfile("E://profiles")
p.accept_untrusted_certs = True
if user_agent:
p.set_preference("general.useragent.override", user_agent)
capabilities = DesiredCapabilities().FIREFOX.copy()
capabilities['acceptInsecureCerts'] = True
if proxy:
p.set_proxy(proxy)
browser = Firefox(firefox_profile=p, capabilities=capabilities)
return browser
示例4: test_manual_proxy_is_set_in_profile
# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import set_proxy [as 别名]
def test_manual_proxy_is_set_in_profile():
profile = FirefoxProfile()
proxy = Proxy()
proxy.no_proxy = 'localhost, foo.localhost'
proxy.http_proxy = 'some.url:1234'
proxy.ftp_proxy = None
proxy.sslProxy = 'some2.url'
profile.set_proxy(proxy)
assert profile.default_preferences["network.proxy.type"] == ProxyType.MANUAL['ff_value']
assert profile.default_preferences["network.proxy.no_proxies_on"] == 'localhost, foo.localhost'
assert profile.default_preferences["network.proxy.http"] == 'some.url'
assert profile.default_preferences["network.proxy.http_port"] == 1234
assert profile.default_preferences["network.proxy.ssl"] == 'some2.url'
assert "network.proxy.ssl_port" not in profile.default_preferences
assert "network.proxy.ftp" not in profile.default_preferences
示例5: test_unspecified_proxy_is_set
# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import set_proxy [as 别名]
def test_unspecified_proxy_is_set():
profile = FirefoxProfile()
proxy = Proxy()
profile.set_proxy(proxy)
assert "network.proxy.type" not in profile.default_preferences
示例6: test_none_proxy_is_set
# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import set_proxy [as 别名]
def test_none_proxy_is_set():
profile = FirefoxProfile()
proxy = None
with pytest.raises(ValueError):
profile.set_proxy(proxy)
assert "network.proxy.type" not in profile.default_preferences