snapshot-selenium icon indicating copy to clipboard operation
snapshot-selenium copied to clipboard

在docker容器中渲染图片遇到问题

Open nishizhumagu opened this issue 5 years ago • 3 comments

我将程序部署在服务器后,发现运行make_snapshot提示:DevToolsActivePort file doesn't exist。 通过分析发现,在docker容器root权限下,chrome无法运行,需要在使用selenium调用chromedriver时为其添加参数”—no-sandbox”。 建议在get_chrome_driver函数在添加“—headless”参数的同时,加上上述参数。或者,为get_chrome_driver函数添加关键字参数,让使用者可以自行添加参数。

nishizhumagu avatar Dec 18 '19 15:12 nishizhumagu

我将程序部署在服务器后,发现运行make_snapshot提示:DevToolsActivePort file doesn't exist。 通过分析发现,在docker容器root权限下,chrome无法运行,需要在使用selenium调用chromedriver时为其添加参数”—no-sandbox”。 建议在get_chrome_driver函数在添加“—headless”参数的同时,加上上述参数。或者,为get_chrome_driver函数添加关键字参数,让使用者可以自行添加参数。

在snapshot.py里面设置吗?为什么我设置了还是不行……

accartisan avatar Apr 01 '20 03:04 accartisan

我将程序部署在服务器后,发现运行make_snapshot提示:DevToolsActivePort file doesn't exist。 通过分析发现,在docker容器root权限下,chrome无法运行,需要在使用selenium调用chromedriver时为其添加参数”—no-sandbox”。 建议在get_chrome_driver函数在添加“—headless”参数的同时,加上上述参数。或者,为get_chrome_driver函数添加关键字参数,让使用者可以自行添加参数。

解决了,本地的没有同步到服务器,也是醉了。 def get_chrome_driver(): options = webdriver.ChromeOptions() options.add_argument("headless") options.add_argument('no-sandbox') return webdriver.Chrome(options=options) 改为这样即可

accartisan avatar Apr 01 '20 03:04 accartisan

对,没有 X window sever 的话, headless 是必须的

chfw avatar Apr 01 '20 12:04 chfw