selenium.common.exceptions.WebDriverException:消息:进程意外关闭,状态为1

时间:2018-06-04 09:02:02

标签: selenium firefox webdriver geckodriver

版本: firefox:Mozilla Firefox 61.0 geckodriver:geckodriver v0.20.1

我只尝试过以下代码:

from selenium import webdriver

browser = webdriver.Firefox()

但是收到如下错误:

Traceback (most recent call last):
  File "my.py", line 3, in <module>
    browser = webdriver.Firefox()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 170, in __init__
keep_alive=True)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 156, in __init__
self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 245, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 314, in execute
self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status: 1

和geckodriver.log:

  

1528101123327 geckodriver INFO geckodriver 0.20.1

     

1528101123336 geckodriver INFO收听127.0.0.1:43481

     

1528101124336 mozrunner :: runner INFO运行命令:&#34; / usr / bin / firefox&#34; &#34; -marionette&#34; &#34; -profile&#34; &#34; /tmp/rust_mozprofile.y93GPXwtXuKC"

     

不支持在常规用户的会话中以root身份运行Firefox。 ($ XAUTHORITY是/home/username/.Xauthority,由用户名拥有。)

它只会在 root帐户中出现问题,请帮助..

1 个答案:

答案 0 :(得分:0)

此错误消息......

Running Firefox as root in a regular user's session is not supported. ($XAUTHORITY is /home/keti/.Xauthority which is owned by keti.)

...暗示您要么尝试将 Firefox浏览器作为 root 用户调用,要么将 Firefox浏览器作为 root < / strong>在非根会话中。

根据User's Firefox process runs as root (if root is running Firefox),两个案例都不受支持,而且应该相对难以实现。但从技术上讲,它仍然是可能的(因为--new-instance和--no-remote标志可用于控制远程控制)但是X11的许可安全模型意味着用户应该基本上将用户帐户视为具有无密码sudo。 / p>

有几个问题如下:

使用 Firefox v60.0的GA(一般可用性) Mozilla团队决定Disallow Firefox from running as sudo为: