簡體   English   中英

如何修復python-selenium中的“無法連接到Mir”錯誤?

[英]How to fix “Failed to connect to Mir” error in python-selenium?

當我准備通過以下命令獲取Webdriver時,在server.log彈出以下錯誤時,我將開發一些硒測試(使用無頭firefox運行):

driver = webdriver.Firefox(firefox_profile = profile, log_path = logfile)

這是錯誤:

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

我不記得有任何改變。 它只是工作了一百多次。 如何解決該錯誤?

  • python 2.7.12
  • Firefox:Mozilla Firefox 57.0.3
  • 壁虎:0.19.1
  • 硒:3.8.0

錯誤說明了一切:

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

這實質上意味着DISPLAY屬性設置不正確。

在.bashrc中添加以下配置:

export DISPLAY=:0

在Ubuntu 16.04上的Gnome,正確的值為DISPLAY=:1 (不是DISPLAY=:0

該問題可能是由於/ etc / sudoers中的env_keep變量引起的。 因此,一種永久的解決方案是使用gedit或sudo visudo在/ etc / sudoers的末尾添加以下行:

Defaults env_keep+="DISPLAY"

注意:有關詳細討論,請參見無法連接到Mir:無法連接到服務器套接字:無此類文件或目錄

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM