我将 Java 与 selenium 一起使用,并且我想使用 browsermob:我对不同的浏览器使用相同的代码,例如 firefox:
BrowserMobProxyServer proxyServer = new BrowserMobProxyServer();
proxyServer.start();
proxyServer.setHarCaptureTypes(CaptureType.getAllContentCaptureTypes());
proxyServer.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);
Proxy proxy = ClientUtil.createSeleniumProxy(proxyServer);
DesiredCapabilities dccFirefox = DesiredCapabilities.firefox();
dccFirefox.setCapability(CapabilityType.PROXY, proxy);
this.driver = new FirefoxDriver(dccFirefox);
在 Firefox 中出现错误:
org.openqa.selenium.SessionNotCreatedException: InvalidArgumentError: Expected [object Undefined] undefined to be an integer
Build info: version: '3.5.1', revision: '9c21bb67ef', time: '2017-08-17T15:26:08.955Z'
System info: host: 'BEN-PLL-ST1-HP', ip: '192.168.1.9', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_141'
Driver info: driver.version: FirefoxDriver
remote stacktrace: stack backtrace:
0: 0x4bb74f - <no info>
1: 0x4bbea9 - <no info>
2: 0x43ce8d - <no info>
3: 0x44ce14 - <no info>
4: 0x44944a - <no info>
5: 0x4203e1 - <no info>
6: 0x407dc7 - <no info>
7: 0x6d95b9 - <no info>
8: 0x4173a7 - <no info>
9: 0x6d38b3 - <no info>
10: 0x775559cd - BaseThreadInitThunk
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$24(ProtocolHandshake.java:360)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:363)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:137)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:641)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:254)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:191)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:103)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:137)
Chrome打开正常但页面无法打开,在控制台出现错误:
Failed to load resource: net::ERR_EMPTY_RESPONSE
net::ERR_PROXY_CONNECTION_FAILED
有人知道为什么会发生此错误吗?