【发布时间】:2021-02-09 20:51:29
【问题描述】:
抱歉,我阅读了几个主题,但找不到解决方案。所以,我想做的是在 WSL 上使用 Selenium 和 firefox。代码如下所示:
def getHTML_(self):
'''
getting HTML with beautifulsoup and selenium
'''
options = Options()
options.set_headless(headless=True)
options.log.level = "trace"
browser = webdriver.Firefox(firefox_options=options)
我得到的是以下(已知)错误:
selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process
.log 说:
1603805101772 mozrunner::runner INFO 运行命令:“/usr/bin/firefox”“-marionette”“-foreground”“-no-remote”“-profile”“/tmp/rust_mozprofilehybl9w” 错误:未指定 DISPLAY 环境变量 1603805357626 mozrunner::runner INFO 运行命令:“/usr/bin/firefox”“-marionette”“-headless”“-foreground”“-no-remote”“-profile”“/tmp/rust_mozprofile2x1kmq” *** 您正在以无头模式运行。 因通道错误退出。
然后跟随一个很长的列表
[Parent][MessageChannel] 错误:
...最终导致杀死错误。
我尝试了不同的 firefox 版本、geckodriver、selenium 组合。其中最新版本 Selenium 3.14、geckodriver 0.27、firefox 82。没有任何效果。我是否正确地认为网络驱动程序仍在尝试首先在没有无头模式的情况下启动 Firefox?!但为什么?我正在传递它应该以无头模式运行的论点,不是吗?
感谢您的帮助!
【问题讨论】:
标签: python selenium firefox windows-subsystem-for-linux geckodriver