“组件未初始化"; nsresult:"0xc1f30001(NS_ERROR_NOT_INITIALIZED)" Selenium GeckoDriver和Mozilla错误 [英] "Component not initialized" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" error with Selenium GeckoDriver and Mozilla
问题描述
我试图在Firefox中执行我的代码,有时它可以工作,但大多数情况下我会出现以下异常:
I am trying to execute my code in Firefox, sometimes it works but majority of time i get exception as:
[Exception... "Component not initialized" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: chrome://marionette/content/dom.js :: addEventListener :: line 67" data: no]
它从上周开始发生,以前对我来说还不错.
Its happening from last week, previously it was working fine for me.
推荐答案
NS_ERROR_NOT_INITIALIZED 类似于尝试使用尚未初始化的组件或对象.这些组件通常提供一个初始化方法,通常称为Init
,必须在使用任何其他方法之前调用它.
NS_ERROR_NOT_INITIALIZED resembles an attempt which was made to use a component or object which has not yet been initialized. These components usually provide an initialization method, often called Init
which must be called before any other methods which are being used.
但是,此错误消息...
However, this error message...
[Exception... "Component not initialized" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: chrome://marionette/content/dom.js :: addEventListener :: line 67" data: no]
...表示牵线木偶在调用 dom.js
...implies that the Marionette threw an error while invoking addEventListener
as defined in dom.js
您的代码试用版和相关的 HTML DOM 可以帮助我们调试以更好的方式发行.但是,似乎addEventListener
甚至在完全呈现 DOM树之前就被调用为时过早.更具体地说,甚至在 Browser Client (即Web浏览器)达到'document.readyState'
等于"complete"
之前,就调用了addEventListener
.通常,一旦满足此条件, Selenium 执行下一个代码行.
Your code trials and the relevant HTML DOM would have helped us to debug the issue in a better way. However it seems the addEventListener
was invoked too early even before the DOM Tree was completely rendered. To be more specific addEventListener
was invoked even before the Browser Client (i.e. the Web Browser) have attained 'document.readyState'
equal to "complete"
. Generally once this condition is fulfilled Selenium performs the next line of code.
一种快速的解决方案是,在尝试与新加载的网页上的任何元素进行交互之前,您需要为以下两个
A quick solution will be to before you try to interact with any of the element on a fresh loaded webpage you need to induce WebDriverWait for either of the following expected_conditions:
-
Python :
-
代码块:
Code Block:
driver.get("https://stackoverflow.com");
WebDriverWait(driver, 10).until(EC.title_contains("Stack"))
print("Page Title is : "+driver.title)
控制台输出:
Console Output:
Page Title is : Stack Overflow - Where Developers Learn, Share, & Build Careers
Java :
-
代码块:
Code Block:
driver.get("https://stackoverflow.com");
new WebDriverWait(driver, 10).until(ExpectedConditions.titleContains("Stack"));
System.out.println("Page Title is : "+driver.getTitle());
控制台输出:
Console Output:
Page Title is : Stack Overflow - Where Developers Learn, Share, & Build Careers
- 将 JDK 升级到最新级别 JDK 8u221 .
- 将硒升级到当前级别> 版本3.141.59 > .
- 将 GeckoDriver 升级到 GeckoDriver v0 .25.0 级别.
- 确保所使用的二进制文件的版本兼容.
- Upgrade JDK to recent levels JDK 8u221.
- Upgrade Selenium to current levels Version 3.141.59.
- Upgrade GeckoDriver to GeckoDriver v0.25.0 level.
- Ensure that the version of the binaries you are using are compatable.
- GeckoDriver存在于所需位置.
- GeckoDriver对非root用户具有可执行权限.
- 将 Firefox 版本升级到 Firefox v69.0 级别. 通过 IDE
- 清理您的项目工作区和重建您的项目,并且仅具有必需的依赖项.
- 如果您的基本 Web客户端版本太旧,则将其卸载并安装最新版本的 Web客户端 GA.
- 进行系统重启.
- 以非root用户身份执行
Test
. - 始终在
tearDown(){}
方法中调用driver.quit()
以关闭&优雅地销毁 WebDriver 和 Web Client 实例. - GeckoDriver is present in the desired location.
- GeckoDriver is having executable permission for non-root users.
- Upgrade Firefox version to Firefox v69.0 levels.
- Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
- If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
- Take a System Reboot.
- Execute your
Test
as a non-root user. - Always invoke
driver.quit()
withintearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully. - WebDriverException:消息:异常……失败" nsresult:使用Selenium Python保存较大的html文件时,"0x80004005(NS_ERROR_FAILURE)"
- [org.openqa.selenium.WebDriverException:异常…使用带有Selenium Java的GeckoDriver和Tor浏览器时出现未初始化组件"错误
- WebDriverException: Message: Exception… "Failure" nsresult: "0x80004005 (NS_ERROR_FAILURE)" while saving a large html file using Selenium Python
- [org.openqa.selenium.WebDriverException: Exception… "Component not initialized" error using GeckoDriver and Tor browser with Selenium Java
您可以在以下位置找到一些相关的讨论:
You can find a couple of relevant discussions in:
在将窗口切换到底部停靠栏时发生"NS_ERROR_NOT_INITIALIZED".
这篇关于“组件未初始化"; nsresult:"0xc1f30001(NS_ERROR_NOT_INITIALIZED)" Selenium GeckoDriver和Mozilla错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!