[英]How to set browser preference in PhantomJS using Selenium
Is there any way to use browser preference like "network.negotiate-auth.trusted-uris"
in phantomJS. 有什么方法可以在phantomJS中使用浏览器首选项,例如
"network.negotiate-auth.trusted-uris"
。
Below is the syntax for selenium with firefox: 下面是使用firefox硒的语法:
p_profile = webdriver.FirefoxProfile()
p_profile.set_preference("network.negotiate-auth.trusted-uris", "https://xx.com")
driver = webdriver.Firefox(p_profile)
driver.get("https://xx.com")
Is there any similar feature available in PhantomJS. PhantomJS中是否有任何类似的功能可用。
You can pass desired_capabilities
keyword argument when you create PhantomJS
object. 创建
PhantomJS
对象时,可以传递desired_capabilities
关键字参数。
For example, to change User-Agent header: 例如,要更改User-Agent标头:
from selenium import webdriver
cap = webdriver.DesiredCapabilities.PHANTOMJS.copy()
cap['phantomjs.page.settings.userAgent'] = 'asdf'
driver = webdriver.PhantomJS(desired_capabilities=cap)
driver.get('http://httpbin.org/headers')
print(driver.page_source)
driver.quit()
Check settings
- PhantomJS for other available settings. 检查
settings
-PhantomJS其他可用设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.