python3+selenuim+firefox+geckodriver 报错:invalid argument: can't kill an exited p

小带鱼 2020-04-18 09:15:17
selenium 版本3.141.0
python 版本3.7.7
firefox 版本68.6.0esr
geckodriver 版本0.26.0
始终在Linux下运行不来。头疼。
直接运行报错:
selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process
查看geckodriver.log
里面写着
Failed to open connection to "session" message bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Running without a11y support!
Error: no DISPLAY environment variable specified

这到底是不是版本对应不上的问题??
firefox和geckodriver 都是最新版
firefox直接用yum remove firefox安装,geckodriver 是去官网下载的最新版本

[root@data-download bin]# geckodriver -h
geckodriver 0.26.0 (e9783a644016 2019-10-10 13:38 +0000)
WebDriver implementation for Firefox
[root@data-download lib64]# firefox -version
Failed to open connection to "session" message bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Running without a11y support!
Mozilla Firefox 68.6.0esr
[root@data-download /]# python3
Python 3.7.7 (default, Apr 17 2020, 13:56:16)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from selenium import webdriver
>>> option = webdriver.FirefoxOptions()
>>> option.add_argument('headless')
>>> option.add_argument('no-sandbox')
>>> option.add_argument('disable-dev-shm-usage')
>>> driver = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver', options=option)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/python3/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
keep_alive=True)
File "/usr/local/python3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/python3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/python3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/python3/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process

>>>


[root@data-download /]# cat geckodriver.log
Failed to open connection to "session" message bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
1587215249839 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "headless" "no-sandbox" "disable-dev-shm-usage" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofileiiBFaQ"
Failed to open connection to "session" message bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Running without a11y support!
Error: no DISPLAY environment variable specified
...全文
584 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

37,741

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧