Max*_*rai 36 firefox proxy selenium-webdriver foxyproxy
有没有办法设置firefox的代理设置?我在这里找到了有关FoxyProxy的信息,但是当Selenium工作时,插件在窗口中被取消激活.
小智 49
值network.proxy.http_port应为整数(不应使用引号),并network.proxy.type应设置为1(ProxyType.MANUAL,手动代理设置)
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "localhost");
profile.setPreference("network.proxy.http_port", 3128);
WebDriver driver = new FirefoxDriver(profile);
Run Code Online (Sandbox Code Playgroud)
Vic*_*tor 22
我刚刚对这个问题感兴趣了几天,我很难找到HTTPS的答案,所以这是我对Java的看法:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "proxy.domain.example.com");
profile.setPreference("network.proxy.http_port", 8080);
profile.setPreference("network.proxy.ssl", "proxy.domain.example.com");
profile.setPreference("network.proxy.ssl_port", 8080);
driver = new FirefoxDriver(profile);
Run Code Online (Sandbox Code Playgroud)
陷入困境:只输入域而不是http://proxy.domain.example.com,属性名是.ssl和不.https
我现在有更多的乐趣试图让它接受我自己签署的证书......
SSH*_*SSH 18
查看文档页面.
调整现有的Firefox配置文件
您需要更改"network.proxy.http"和"network.proxy.http_port"配置文件设置.
FirefoxProfile profile = new FirefoxProfile();
profile.addAdditionalPreference("network.proxy.http", "localhost");
profile.addAdditionalPreference("network.proxy.http_port", "3128");
WebDriver driver = new FirefoxDriver(profile);
Run Code Online (Sandbox Code Playgroud)
只是添加到上面给出的解决方案.,
添加"network.proxy.type"的可能性列表(整数值).
0 - Direct connection (or) no proxy.
1 - Manual proxy configuration
2 - Proxy auto-configuration (PAC).
4 - Auto-detect proxy settings.
5 - Use system proxy settings.
Run Code Online (Sandbox Code Playgroud)
因此,根据我们的要求,应该按照下面的说明设置"network.proxy.type"值.
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
WebDriver driver = new FirefoxDriver(profile);
Run Code Online (Sandbox Code Playgroud)
WebDriver API已更改.用于设置代理的当前代码段是
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.http", "localhost");
profile.setPreference("network.proxy.http_port", "3128");
WebDriver driver = new FirefoxDriver(profile);
Run Code Online (Sandbox Code Playgroud)
如果您有自动配置网址 -
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("network.proxy.type", 2);
firefoxProfile.setPreference("network.proxy.autoconfig_url", "http://www.etc.com/wpad.dat");
firefoxProfile.setPreference("network.proxy.no_proxies_on", "localhost");
WebDriver driver = new FirefoxDriver(firefoxProfile);
Run Code Online (Sandbox Code Playgroud)
小智 5
这是一个使用的java示例DesiredCapabilities.我用它将硒测试泵入jmeter.(只对HTTP请求感兴趣)
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
String myProxy = "localhost:7777"; //example: proxy host=localhost port=7777
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY,
new Proxy().setHttpProxy(myProxy));
WebDriver webDriver = new FirefoxDriver(capabilities);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
93193 次 |
| 最近记录: |