将自定义配置文件文件夹设置为Firefox时,硒不起作用

时间:2019-09-07 22:17:15

标签: java selenium selenium-webdriver geckodriver selenium-firefoxdriver

我正在将硒与Java一起用于在Firefox上抓取某些网站。

使用默认设置,一切正常

FirefoxOptions options = new FirefoxOptions();
new FirefoxDriver(options).get("https://www.facebook.com");

并打开Facebook页面 但是,如果我尝试为firefox配置文件定义自定义文件夹

 FirefoxOptions options = new FirefoxOptions();
options.addArguments("-profile D:\\Area de Trabalho\\asdasd");
    new FirefoxDriver(options).get("https://www.facebook.com");

1将创建文件夹
其中将创建2吨文件(自然的Firefox配置文件)
3firefox将在第一次打开时打开的默认页面中打开
4java程序将继续运行一段时间,然后由于以下异常而崩溃:

1567894214346   mozrunner::runner   INFO    Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile D:\\Area de Trabalho\\asdasd"
Exception in thread "main" org.openqa.selenium.WebDriverException: connection refused
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'BOLDS-A62', ip: '192.168.142.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '12.0.2'
Driver info: driver.version: MasterDriver
remote stacktrace: 
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
    at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
    at com.tomatedigital.selenium.MasterDriver.createMasterDriver(MasterDriver.java:213)
    at com.tomatedigital.selenium.MasterDriver.createMasterDriver(MasterDriver.java:108)
    at com.tomatedigital.instagramwebapi.api.InstagramBrowser.create(InstagramBrowser.java:120)
    at com.tomatedigital.instagramwebapi.api.InstagramBrowser.main(InstagramBrowser.java:162)

它碰到我设置的任何文件夹

0 个答案:

没有答案