WebDriverException:消息:“浏览器似乎已经退出,然后我们才能连接.输出为:错误:未指定显示 [英] WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified

查看:65
本文介绍了WebDriverException:消息:“浏览器似乎已经退出,然后我们才能连接.输出为:错误:未指定显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行我的测试用例时,我的任何测试程序都尝试启动firefox,但出现错误.我正在使用robotframework,Selenium2Library和python 2.7.

When running my test case, any my test program try to start firefox, I got Error. I am using robotframework, Selenium2Library and python 2.7.

1Login   [ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open
| FAIL |
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n'

我的CentOS服务器上有Xwindows.我使用yum安装了firefox.我的firefox已安装在firefox: /usr/bin/firefox /usr/lib64/firefox /usr/share/man/man1/firefox.1.gz

I have Xwindows on my CentOS server. I installed firefox using yum. My firefox was installed in firefox: /usr/bin/firefox /usr/lib64/firefox /usr/share/man/man1/firefox.1.gz

这是怎么了?有没有人有类似的经历?有任何参考或建议吗?

What is wrong here? Has anyone had similar experiences? Any references or advice? thx

运行演示后的结果.

==============================================================================
Login Tests                                                                   
==============================================================================
Login Tests.Invalid Login :: A test suite containing tests related to inval...
==============================================================================
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open
Invalid Username                                                      | FAIL |
Parent suite setup failed:
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n'
------------------------------------------------------------------------------
Invalid Password                                                      | FAIL |
Parent suite setup failed:
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n'
------------------------------------------------------------------------------
Invalid Username And Password                                         | FAIL |
Parent suite setup failed:
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n'
------------------------------------------------------------------------------
Empty Username                                                        | FAIL |
Parent suite setup failed:
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n'
------------------------------------------------------------------------------
Empty Password                                                        | FAIL |
Parent suite setup failed:
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n'
------------------------------------------------------------------------------
Empty Username And Password                                           | FAIL |
Parent suite setup failed:
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n'
------------------------------------------------------------------------------
Login Tests.Invalid Login :: A test suite containing tests related... | FAIL |
Suite setup failed:
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n' 

6 critical tests, 0 passed, 6 failed
6 tests total, 0 passed, 6 failed
==============================================================================
Login Tests.Valid Login :: A test suite with a single test for valid login....
==============================================================================
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open
Valid Login                                                           | FAIL |
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n'
------------------------------------------------------------------------------
Login Tests.Valid Login :: A test suite with a single test for val... | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Login Tests                                                           | FAIL |
7 critical tests, 0 passed, 7 failed
7 tests total, 0 passed, 7 failed
==============================================================================
Output:  /root/Downloads/robotframework-selenium2library/demo/output.xml
Log:     /root/Downloads/robotframework-selenium2library/demo/log.html
Report:  /root/Downloads/robotframework-selenium2library/demo/report.html

推荐答案

硒需要显示,而Linux没有显示,您需要下载虚拟显示( xvfb ).然后启动虚拟显示服务器并export显示.

Selenium needs a display and as Linux does not have one , you need to download a virtual display (xvnc/xvfb). Then start the virtual display server and export the display.

然后它应该可以工作

这篇关于WebDriverException:消息:“浏览器似乎已经退出,然后我们才能连接.输出为:错误:未指定显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆