问题描述
我正在使用一个非常复杂的设置来测试各种非公共网页.我使用 jenkins
在 docker
图像中运行 python-selenium
测试.这样,我就完全独立于 jenkins 环境,可以创建自己的环境.在这个环境中,我安装了以下软件:
I am using a very complex setup to test various non-public webpages. I use jenkins
to run the python-selenium
tests within a docker
image. That way, I am completely independent of the jenkins environment and can create my own environment. In this environment I have the following software installed:
- Ubuntu 16.04.3
- Firefox:Mozilla Firefox 57.0.1
- 壁虎驱动程序:0.18.0
- 鼻子测试:1.3.7
- 硒:3.8.0
运行测试时,大部分都成功了,我在 geckodriver.log
输出消息中看到类似
When running the tests, which mostly succeed, I see in the geckodriver.log
output messages like
(firefox:55): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message
我的问题:
- 这条消息是什么意思?
- 这是否可以说明有时测试失败的原因?
- 如果是,如何解决?
推荐答案
您看到的错误是:
(firefox:55): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message
所以很明显 Firefox 尝试连接到 D-BUS 守护进程 并且由于 dbus-launch 异常终止而失败.
So it is clear Firefox attempts to connect to D-BUS daemon and fails as dbus-launch gets terminated abnormally.
dbus-launch 基本上是通过 Firefox 通过 shell 脚本启动消息总线的实用程序.它通常会从用户的登录脚本中调用.dbus-launch 启动会话总线实例并将该实例的地址和 pid
打印到标准输出.
dbus-launch is basically the utility to start a message bus by firefox through a shell script. It would normally be called from a user's login scripts. dbus-launch launches a session bus instance and print the address and pid
of that instance to standard output.
您可以从 中阅读有关 dbus-launch 的更多信息Linux 手册页
You can read more about dbus-launch from the Linux man page
如果您使用 su
(root)、sudo
、suedit
、gksu
,则会出现此错误.主要原因是 DBUS_SESSION_BUS_ADDRESS
在您 su
时保留其值,而不是在 /root/.dbus/session-bus
中取值.
This error can arise if you use su
(root), sudo
, suedit
, gksu
. The main reason is DBUS_SESSION_BUS_ADDRESS
retains its value when you su
instead of picking up the value in /root/.dbus/session-bus
.
在这里你会找到关于GConf 错误:没有运行 D-BUS 守护进程?!如何重新安装或修复?.
另一个可能的原因可能是基本的 Firefox
浏览器版本可能是一个较旧的版本,在该版本上进行了更新以达到当前版本.
Another possible reason may be the base Firefox
Browser version may be an older version on which updates were taken to reach the current version.
有几种解决方案可以解决这个ubuntu 相关问题如下:
There are a couple of solutions available to address this ubuntu related issue as follows :
- 在您启动 Firefox 之前,您必须输入
export $(dbus-launch)
- 然而,这可能会导致
NSS_USE_SHARED_DB
出现另一个错误.因此,您还必须使用export NSS_USE_SHARED_DB=ENABLED
. 最方便的方法是将所有配置放在
.bashrc
文件中:
- Before you start Firefox you have to type
export $(dbus-launch)
- However this may result into another error with
NSS_USE_SHARED_DB
. So you have to useexport NSS_USE_SHARED_DB=ENABLED
as well. The most convenient way would be to put all the configuration with in
.bashrc
file :
export $(dbus-launch)
export NSS_USE_SHARED_DB=ENABLED
firefox &
这个讨论详细讨论了解决方案.
This discussion speaks about the solution in details.
- 如果您的系统上没有安装
dbus-launch
,您必须安装包含 dbus-launch 程序的dbus-x11
包. - 一个有效的解决方案是卸载 Firefox 浏览器的旧基础版本并安装最近发布的 Firefox 浏览器的 GA 版本.
- If
dbus-launch
is not installed on your system you have to installdbus-x11
package which contains the dbus-launch program. - An effective solution would be to uninstall the older base version of Firefox Browser and install a recent released GA version of Firefox Browser.
dbus-launch 的问题已由 Ubuntu 和 Mozila 正确解决.要克服此错误,您需要按照以下步骤操作:
The issue with dbus-launch was addressed properly by both Ubuntu and Mozila. To overcome this error you need to follow the below mentioned steps :
- 保留您的 Ubuntu os 更新了最新补丁发布和更新.
- 始终使用最新发布的 Selenium-Python 客户端,WebDriver 变体例如GeckoDriver 和网络浏览器,例如Firefox 浏览器. 在执行测试之前和之后,通过IDE重新
- 清理和构建项目工作区套房 .在执行测试之前和之后
- 清除浏览器缓存.
- 如果您必须卸载任何Web Client变体(例如Mozilla Firefox),您可以使用Revo Uninstallarem> 使用中等内存扫描,以便丢弃陈旧的注册表设置.
- 定期使用CCleaner工具清除操作系统杂务,包括过时的rust_mozprofile 目录.
- Keep your Ubuntu os updated with the Latest Patch Releases and updates.
- Always use the latest released version of Selenium-Python client, WebDriver variant e.g. GeckoDriver and Web Browser, e.g. Firefox Browser.
- Clean and Build the Project Workspace afresh through your IDE before and after executing your Test Suite.
- Clear the Browser Cache before and after the execution of your Tests.
- If you have to uninstall any of the Web Client variants (e.g. Mozilla Firefox) you can use Revo Uninstallar with Moderate Memory Scan so that the stale registry settings are discarded.
- Use CCleaner tool regularly to wipe away the OS chores including the stale rust_mozprofile directories.
这篇关于“客户端无法连接到 D-BUS 守护进程"是什么意思?意思是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!