【问题标题】:Selenium + Geckodriver + firefox test throws various errorsSelenium + Geckodriver + firefox 测试抛出各种错误
【发布时间】:2021-06-24 09:36:41
【问题描述】:

我正在尝试使用 firefox 进行一些简单的 selenium 测试,但无法使其正常工作。 任务是避免使用驱动程序管理器并使用 Geckodriver。

这是我的代码示例:

@Test
public void checkDownloadPage(){
    System.setProperty("webdriver.gecko.driver", "drivers/windows/geckodriver.exe");
    FirefoxProfile profile = new ProfilesIni().getProfile("TestAutomation");
    FirefoxOptions ffOptions = new FirefoxOptions();
    ffOptions.setProfile(profile);
    WebDriver driver = new FirefoxDriver(ffOptions);
    driver.navigate().to("https://selenium.dev");
    driver.quit();
}

这是控制台输出:

1616876616440   geckodriver INFO    Listening on 127.0.0.1:13593
1616876617340   mozrunner::runner   INFO    Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "--remote-debugging-port" "0" "-foreground" "-no-remote" "-profile" "C:\\Users\\Abaddon\\AppData\\Local\\Temp\\rust_mozprofiles624Y0"
DevTools listening on ws://localhost:54709/devtools/browser/c139d218-070e-445b-89fd-6067dbb4b52a
1616876618916   Marionette  INFO    Listening on port 54695
1616876619397   Marionette  WARN    TLS certificate errors will be ignored for this session
Mar 27, 2021 10:23:39 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
1616876620273   Marionette  INFO    Stopped listening on port 54695
!!! error running onStopped callback: TypeError: callback is not a function

###!!! [Child][RunMessage] Error: Channel closing: too late to send/recv, messages will be lost

1616876620574   RemoteAgent ERROR   unable to stop listener: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIWindowMediator.getEnumerator]"  nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)"  location: "JS frame :: chrome://remote/content/cdp/observers/TargetObserver.jsm :: stop :: line 61"  data: no] Stack trace: stop()@TargetObserver.jsm:61
unwatchForTabs()@TargetList.jsm:71
unwatchForTargets()@TargetList.jsm:38
destructor()@TargetList.jsm:110
close()@RemoteAgent.jsm:124

===============================================
Default Suite
Total tests run: 1, Passes: 1, Failures: 0, Skips: 0
===============================================


Process finished with exit code 0

我在依赖项中拥有的东西的版本:

<version.testng>7.3.0</version.testng>
<version.selenium>4.0.0-beta-2</version.selenium>
<version.guava>30.1-jre</version.guava>
<version.slf4j.nop>2.0.0-alpha1</version.slf4j.nop>
<version.log4j>2.14.1</version.log4j>    
<version.download-maven-plugin>1.6.1</version.download-maven-plugin>
<version.chromedriver>89.0.4389.23</version.chromedriver>
<md5.chromedriver>0bf4bc39f34cee67f5f95afd8a24c191</md5.chromedriver>
<version.geckodriver>v0.29.0</version.geckodriver>
<md5.geckodriver>8e19f65e730bd5960e87c7e42c88c5a7</md5.geckodriver>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>

也尝试使用 selenium 3.141.59,geckodriver 32 位和 64 位,Firefox 是 87.0 版本

真的很想了解如何摆脱这些错误消息。

【问题讨论】:

    标签: selenium-webdriver ui-automation geckodriver selenium-firefoxdriver


    【解决方案1】:

    最好的办法是使用 wedDriver 管理器。这将自动处理所有与浏览器相关的版本。 而不是 system.setProperty() 使用 WebDriverManager.firefoxdriver().setup();

    【讨论】:

    • 尝试通过 WebDriverManager.firefoxdriver().setup(); - 仍然是完全相同的问题。
    【解决方案2】:

    关于这个有一个开放的错误:https://bugzilla.mozilla.org/show_bug.cgi?id=1598832

    【讨论】:

    • 谢谢! :) 现在我更高兴不是我做错了
    猜你喜欢
    • 1970-01-01
    • 2017-08-30
    • 2017-04-04
    • 1970-01-01
    • 2021-12-06
    • 2017-11-01
    • 2021-07-26
    • 1970-01-01
    • 2021-01-29
    相关资源
    最近更新 更多