java使用ChromeDriver设置browsermob代理
我正在尝试设置browsermob,以便在我的selenium项目中工作。我在寻找一种使用ChromeOptions设置代理的方法,但所有来源都告诉我在实例化新ChromeDriver实例之前,使用ChromeOptions进行其他操作,然后将其转换为所需的功能
这是我的代码:
ChromeOptions options = new ChromeOptions();
// Setting some chrome features here
ProxyServer proxyServer = new ProxyServer(4444);
proxyServer.start();
Proxy proxy = proxyServer.seleniumProxy();
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
capabilities.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new ChromeDriver(capabilities); // Error happens here
我使用的是maven存储库中的Webdriver 2.44版。这就是我得到的错误:
java.lang.IllegalAccessError: tried to access field com.google.gson.JsonNull.INSTANCE from class org.openqa.selenium.remote.BeanToJsonConverter
有人知道将代理连接到chromedriver的原因或其他解决方案吗
# 1 楼答案
ChromeDriver不直接支持代理上限。但确实如此 支持将命令行参数传递给chrome进程。和背景 http代理是chrome命令行开关之一。可以设定 详情如下: