关于配置文档以及如何制作便携版 Firefox

关于配置文档以及如何制作便携版 Firefox,第1张

Firefox profile的属性值是可以改变的,比如我们平时可能需要通过代理上网,可以这样修改:

FirefoxProfile profile = new FirefoxProfile()

//使用profile

ProfilesIni allProfiles = new ProfilesIni()

FirefoxProfile profile = allProfiles.getProfile("default")

driver = new FirefoxDriver(profile)

// 使用代理

profile.setPreference(“network.proxy.type”, 1)

// http协议代理配置

profile.setPreference(“network.proxy.http”, proxyIp)

profile.setPreference(“network.proxy.http_port”, proxyPort)

// 所有协议公用一种代理配置,如果单独配置,这项设置为false,再类似于http的配置

profile.setPreference(“network.proxy.share_proxy_settings”, true)

// 对于localhost的不用代理,这里必须要配置,否则无法和webdriver通讯

profile.setPreference(“network.proxy.no_proxies_on”, “localhost”)

// 以代理方式启动firefox

FirefoxDriver ff = new FirefoxDriver(profile)


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/tougao/11273919.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-14
下一篇2023-05-14

发表评论

登录后才能评论

评论列表(0条)

    保存