簡體   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