为此,我已经在互联网上搜寻了几天,似乎找不到任何有效的方法。我已经看到了很多问题/示例,但是没有一个对我有用。
Java 1.8, Eclipse 4.7.3a, Selenium-server-standalone-3.1.2.0.jar, browsermob-core-2.1.5.jar
为了能够设置请求标头,我尝试了15种不同的解决方案,但它们都不起作用,似乎很多东西都适用于所有旧版本。
简单设置,
private BrowserMobProxy proxy = null;
private Proxy seleniumProxy = null;
private DesiredCapabilities capabilities = null;
...
proxy = new BrowserMobProxyServer();
proxy.setTrustAllServers(true);
proxy.start();
proxy.addHeader("myheader", "myvalue");
seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
add header函数没有给出错误,但是似乎没有设置header,我继续设置驱动程序,测试一切正常,但是没有设置header。
此代码正确吗?我错过了什么吗?有人可以实际地为我指出一个简单的例子来说明我正在运行的版本,还是请让我知道我要去哪里了。
谢谢