繁体   English   中英

尝试在Mac OS X上通过GelenoDriver与Selenium一起使用firefoxprofile时出现“未知错误”,“消息”:“连接被拒绝”,“堆栈跟踪”

[英]“unknown error”,“message”:“connection refused”,“stacktrace” while trying to use firefoxprofile through GeckoDriver with Selenium on Mac OS X

我在创建firefox驱动程序时遇到连接拒绝错误。

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命令测试它,我尝试了对gecko驱动程序bin文件的777权限。

还将Gecko驱动程序更新到最新版本(0.24.0)

您的配置看起来不错。

我在Linux中遇到过类似的问题。

  • 在我的情况下,解决方案是测试所有版本的gecko驱动程序,其中一个,它工作。

  • 您还可以检查IDE的os用户(eclipse,intellij)是否与firefox的用户相同。 在我的例子中,eclipse是以root身份开始的,但firefox无法以root用户身份启动。

我希望这对你有帮助。

在使用Selenium v​​3.xGeckoDriver v0.24.0Firefox Quantum v65.0在每次运行Test Execution时使用新的 Firefox Profile时 ,您可以使用以下代码块:

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)中找到详细讨论

我在使用python的 Windows中遇到了同样的问题。 确保您的Firefox浏览器版本也是最新版本。

经过大量搜索后,我终于发现这是因为之前的浏览器实例正在运行。 请记住,不是像我打开的另一个实例,而是之前由selenium打开的实例。 如果可以,请关闭所有后台浏览器进程。 我重新启动了我的系统,只要我记得做browser.quit() ,它就能完美运行。

如果在正确关闭对象之前停止程序,则后台实例有可能继续运行,除非eclipse或您使用的任何IDE关闭它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM