WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified

Nick Dong picture Nick Dong · Sep 16, 2013 · Viewed 9.4k times · Source

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'

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

EDIT:

The results, after I run demos.

==============================================================================
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

Answer

Amey picture Amey · Sep 16, 2013

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.

Then it should work