“未知错误",“消息":“连接被拒绝",“堆栈跟踪";在Mac OS X上尝试通过GeckoDriver和Selenium使用firefoxprofile时
创建firefox驱动程序时出现连接拒绝错误.
I am getting connection refused error while creating a firefox driver.
System.setProperty("webdriver.gecko.driver", "path to gecko driver");
FirefoxOptions options = new FirefoxOptions();
options.setLogLevel(FirefoxDriverLogLevel.FATAL);
options.setAcceptInsecureCerts(true);
options.addArguments("-profile", "./firefoxprofile");
options.setHeadless(true);
LOGGER.info("Completed setting firefox optons");
WebDriver driver = new FirefoxDriver(options);
日志:
1550014357421 mozrunner::runner INFO Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "-marionette" "-profile" "./firefoxprofile" "-foreground" "-no-remote"
1550014357464 geckodriver::marionette DEBUG Waiting 60s to connect to browser on 127.0.0.1:61008
[GFX1-]: [OPENGL] Failed to init compositor with reason: FEATURE_FAILURE_OPENGL_CREATE_CONTEXT
Can't find symbol 'GetGraphicsResetStatus'.
1550014417545 mozrunner::runner DEBUG Killing process 38393
Exiting due to channel error.
1550014417592 webdriver::server DEBUG <- 500 Internal Server Error {"value":{"error":"unknown error","message":"connection refused","stacktrace":""}}
Web服务器正在运行,我可以使用curl命令对其进行测试,并尝试使用壁虎驱动程序bin文件的777权限.
Web server is running and I could able to test it with curl command and I tried with 777 permissions on gecko driver bin file.
还将Gecko驱动程序更新为最新版本(0.24.0)
Also updated Gecko driver to latest version (0.24.0)
在使用 Selenium v3.x , GeckoDriver v0.24.0 和 Firefox Quantum v65时.0 要在 Test Execution 的每次运行中使用 new Firefox配置文件,您可以使用以下代码块:>
While working with Selenium v3.x, GeckoDriver v0.24.0 and Firefox Quantum v65.0 to use a new Firefox Profile on every run of your Test Execution you can use the following code block :
System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe");
FirefoxOptions options = new FirefoxOptions();
options.setProfile(new FirefoxProfile());
options.setLogLevel(FirefoxDriverLogLevel.FATAL);
options.setAcceptInsecureCerts(true);
options.setHeadless(true);
WebDriver driver = new FirefoxDriver(options);
driver.get("https://www.google.com");
您可以在中找到详细的讨论构造函数FirefoxDriver(org.openqa.selenium.firefox.FirefoxProfile)