selenium-webdriver - Selenium + Geckodriver + firefox 测试抛出各种错误
问题描述
我正在尝试使用 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 版本
真的很想了解如何摆脱该错误消息。
解决方案
推荐阅读
- dita - 可以使用 CSS 文件生成 PDF 输出吗?
- html - Apache 基本认证后台
- node.js - Microsoft bot builder V4 nodejs 获取用户电子邮件
- javascript - 计算数量和价格输出jquery
- reactjs - 使用 Deck.GL 作为 Webpack 外部
- python - 如何访问平面列表并对python中的第二个值执行数学函数
- jquery - 当其他行中的所有复选框都隐藏时,表头中的复选框需要隐藏
- python - 如何在 elasticsearch dsl (elasticsearch-dsl-py) 中使用存储桶、指标或管道进行多层聚合
- javascript - 当我在反应完整日历中专注于日历之外时,无法保持选择突出显示
- android - Flutter:重定向后循环调用StatefulWidget