4

I have been running Selenium test in Linux and I am getting the following error:

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: no display specified

After googling I can see I need to export DISPLAY=:0 to circumvent this problem.

However it is not clear to me why this needs to be done.

Exploring
  • 2,493
  • 11
  • 56
  • 97

3 Answers3

1

If you have a server without GUI then : You have to install Xvfb: Install xvfb tutorial Then you need to run the following commands :

  1. export DISPLAY=:99
  2. Xvfb :99 -screen 0 1920x1080x24 > /dev/null 2>&1 &
  3. your_command_to_launch_browser_or_application_here
SofianD
  • 47
  • 7
0

Install xvnc,

Then start it by simply typing

vncserver

this will be followed by the terminal asking to enter a passphrase, and a display number will be returned.

Export that Display number to enable selenium to launch the firefox browser on that virtual display.

You can export like so

export DISPLAY=:1 # Assuming 1 is the display number returned. 

Using the above steps will hopefully give you more meaning to what/why you are exporting/displaying. While, the reason to export is to provide a virtual display so that firefox launches "normally", and selenium can use native interactions to interact with it.

Amey
  • 8,470
  • 9
  • 44
  • 63
0

Can you re-phrase your a qs a bit with more specifications like which OS are you using , which selenium jar are you using which N-unit framework are you taking for writing test cases and which Programmibg language are you using for writing test cases ?

I also faced the same problem and it was resolved by taking these steps : 1. I had old selemium-server-standalone-jar I updated it to latest 2.40 2. I had old FF version I tool FF 29 . And I used junit for test cases designing and it worked for me.

Please let me know if it makes sense to you as I am using Windows machine.And the issue was:

xception: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
ser\\AppData\\Local\\Temp\\anonymous6184290163469300810webdriver-profile\\extensions\\fxdriver@googlecode.com","mtime":1401260795981,"rdfTime":1401260791866}}}]
*** LOG addons.xpi-utils: Opening XPI database C:\Users\user\AppData\Local\Temp\anonymous6184290163469300810webdriver-profile\extensions.json
*** LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
*** LOG addons.xpi-utils: Make addon app-profile:fxdriver@googlecode.com visible
*** LOG DeferredSave/extensions.json: Save changes
*** LOG DeferredSave/extensions.json: Save changes
*** LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
*** LOG addons.xpi-utils: Make addon app-global:{972ce4c6-7e08-4474-a285-3208198ce6fd} visible
*** LOG DeferredSave/extensions.json: Save changes
*** LOG DeferredSave/extensions.json: Save changes
*** LOG addons.xpi: New add-on otis@digitalpersona.com installed in winreg-app-global
*** LOG addons.xpi-utils: Make addon winreg-app-global:otis@digitalpersona.com visible
*** LOG DeferredSave/extensions.json: Save changes
*** LOG DeferredSave/extensions.json: Save changes
*** LOG addons.xpi: New add-on ext@VideoPlayerV3beta652.net installed in winreg-app-global
*** LOG addons.xpi-utils: Make addon winreg-app-global:ext@VideoPlayerV3beta652.net visible
*** LOG DeferredSave/extensions.json: Save changes
*** LOG DeferredSave/extensions.json: Save changes
*** LOG addons.xpi: New add-on ext@MediaPlayerV1alpha512.net installed in winreg-app-global
*** LOG addons.xpi-utils: Make addon winreg-app-global:ext@MediaPlayerV1alpha512.net visible
*** LOG DeferredSave/extensions.json: Save changes
*** LOG DeferredSave/extensions.json: Save changes
*** LOG addons.xpi: New add-on {55A8EC97-6AF6-442c-877F-11C51DBD162D} installed in winreg-app-global
*** LOG addons.xpi-utils: Make addon winreg-app-global:{55A8EC97-6AF6-442c-877F-11C51DBD162D} visible
*** LOG DeferredSave/extensions.json: Save changes
*** LOG DeferredSave/extensions.json: Save changes
*** LOG addons.xpi: Updating database with changes to installed add-ons
*** LOG addons.xpi-utils: Updating add-on states
*** LOG addons.xpi-utils: Writing add-ons list
*** LOG DeferredSave/extensions.json: Starting timer
*** LOG DeferredSave/extensions.json: Starting write
*** LOG DeferredSave/extensions.json: Write succeeded
*** LOG addons.xpi-utils: XPI Database saved, setting schema version preference to 16
*** LOG addons.manager: shutdown
*** LOG addons.xpi: shutdown
*** LOG addons.xpi-utils: shutdown
*** LOG addons.xpi: Notifying XPI shutdown observers
*** LOG addons.manager: Async provider shutdown done
System JS : ERROR resource://gre/modules/BookmarkHTMLUtils.jsm:798 - NS_ERROR_UNEXPECTED: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsINavBookmarksService.removeFolderChildren]
System JS : ERROR resource://app/components/nsBrowserGlue.js:1713 - NS_ERROR_UNEXPECTED: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIAnnotationService.getItemsWithAnnotation]
System JS : ERROR resource://gre/modules/BookmarkHTMLUtils.jsm:835 - NS_ERROR_UNEXPECTED: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsINavBookmarksService.runInBatchMode]
*** LOG addons.xpi: startup
*** LOG addons.xpi: Skipping unavailable install location app-system-local
*** LOG addons.xpi: Skipping unavailable install location app-system-share
*** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: C:\Users\user\AppData\Local\Temp\anonymous6184290163469300810webdriver-profile\extensions\webdriver-staging
*** LOG addons.xpi: checkForChanges
*** LOG addons.xpi: No changes found
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
JavaScript error: chrome://browser/content/urlbarBindings.xml, line 650: aUrl is undefined
*** LOG addons.manager: shutdown
*** LOG addons.xpi: shutdown
*** LOG addons.xpi: Notifying XPI shutdown observers
*** LOG addons.manager: Async provider shutdown done

    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:106)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
Khyati Sehgal
  • 375
  • 1
  • 6
  • 21