I was about to develop some selenium tests (running with headless firefox), when the following error popped up in the server.log
when I was about to acquire the webdriver via this command:
driver = webdriver.Firefox(firefox_profile = profile, log_path = logfile)
Here is the error:
1518520162032 geckodriver::marionette INFO Starting browser /usr/bin/firefox with args ["-marionette"]
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused
Error: cannot open display: :1137
I do not recall to have changed anything. It just worked before like a hundred times. How to fix that error???
The error says it all :
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused
Error: cannot open display: :1137
This essentially means that the DISPLAY
property was not set properly.
Add the following configuration in your .bashrc :
export DISPLAY=:0
Gnome on Ubuntu 16.04, the correct value is DISPLAY=:1
(not DISPLAY=:0
)
The problem might be due to env_keep variable in /etc/sudoers. So a permanent solution would be to add the following line at the end of /etc/sudoers using gedit or using sudo visudo :
Defaults env_keep+="DISPLAY"
Note : For a detailed discussion see Failed to connect to Mir: Failed to connect to server socket: No such file or directory
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.