如何在运行时更改Firefox Web驱动程序代理设置? [英] How to change Firefox web driver proxy settings at runtime?

查看:106
本文介绍了如何在运行时更改Firefox Web驱动程序代理设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Selenium 2.35.0并配置代理设置,例如:

I use Selenium 2.35.0 and configure proxy settings like:

DesiredCapabilities cap = new DesiredCapabilities();
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(proxyStr).setFtpProxy(proxyStr).setSslProxy(proxyStr);
cap.setCapability(CapabilityType.PROXY, proxy);

driver = new FirefoxDriver(firefox, profile, cap);

当我需要更改代理设置时,我强制重启webdriver并拼写其他proxyStr。

When I need to change proxy settings I force to restart webdriver and speify other "proxyStr".

如果没有重新启动webdriver,我怎样才能实现这种变化?

How I can reach this changing without of webdriver restart?

推荐答案

您为任何给定的驱动程序设置代理,它仅在创建WebDriver会话时设置;它不能在运行时更改。即使您获得了创建的会话的功能,您也无法更改它。所以答案是,不,如果你想使用不同的代理设置,你必须开始新的会话。

When you set a proxy for any given driver, it is set only at the time WebDriver session is created; it cannot be changed at runtime. Even if you get the capabilities of the created session, you won't be able to change it. So the answer is, no, you must start a new session if you want to use different proxy settings.

这篇关于如何在运行时更改Firefox Web驱动程序代理设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆