我需要使用远程代理服务器进行测试,但代理需要登录名和密码才能进行授权。我尝试为此使用BrowserMobProxyServer
:
BrowserMobProxy bmp = new BrowserMobProxyServer();
bmp.start();
// This inject my remote proxy ip:port and login password.
bmp.autoAuthorization("111.111.111.111:8000", "l0gVal", "pasVal", AuthType.BASIC);
Proxy proxy = ClientUtil.createSeleniumProxy(bmp);
// I guess if info about this proxy already injected it should work without loin & password form but auth alert whenever appear(
proxy.setHttpProxy("111.111.111.111:8000");
proxy.setSslProxy("111.111.111.111:8000");
ChromeOptions options = new ChromeOptions();
options.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new ChromeDriver(options);
driver.get("https://whoer.net");
帮助我理解我的错误,我确定这是可能的,但是如何。我得到这个例外:
在端口 30000 上启动 ChromeDriver 2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef) 只允许本地连接。2018-04-26 11:45:22 错误 olpimpl.ClientToProxyConnection - (AWAITING_INITIAL) 在 net.lightbody.bmp.util.BrowserMobHttpUtil.removeMatchingPort(BrowserMobHttpUtil.java:274) ~[browsermob-core-2.1.0-beta-6 .jar:na] 在 net.lightbody.bmp.filters.HttpsHostCaptureFilter.clientToProxyRequest(HttpsHostCaptureFilter.java:36) ~[browsermob-core-littleproxy-2.1.0-beta-6.jar:na] 在 net.lightbody.bmp .filters.BrowserMobHttpFilterChain.clientToProxyRequest(BrowserMobHttpFilterChain.java:65) ~[browsermob-core-littleproxy-2.1.0-beta-6.jar:na] at org.littleshoot.proxy.impl.ClientToProxyConnection.doReadHTTPInitial(ClientToProxyConnection.java: 227) ~[littleproxy-1.1.0-beta-bmp-12.jar:na] 在 org.littleshoot。