在Windows的Linux子系统上无法从Selenium启动Chrome [英] Having trouble launching Chrome from Selenium on Linux subsystem for Windows

查看:91
本文介绍了在Windows的Linux子系统上无法从Selenium启动Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一次发贴,因此,如果我遗漏任何明显的内容,我谨向您致歉.我正在尝试在Windows的Linux子系统上的Ubuntu(18.04.3 LTS)版本上通过python3通过Selenium启动Chrome.我在/usr/bin/chromedriver中安装了chromedriver,并通过pip3 install chromedriver-binary安装了二进制文件.这些命令是:

This is my first time posting, so I apologize in advance if I'm missing anything glaringly obvious. I'm attempting to launch Chrome via Selenium through python3 on a version of Ubuntu (18.04.3 LTS) on a Linux subsystem for Windows. I have chromedriver installed in /usr/bin/chromedriver, and installed the binary through pip3 install chromedriver-binary. The commands are:

from selenium import webdriver

driver = webdriver.Chrome()

当我尝试执行第二行时,出现错误

When I try to execute the second line, I get the error

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.).

我一直在闲逛,听起来好像我可能需要传递到Chrome()的路径,但是我什至不确定这是否是问题所在.我肯定会和他们一样环保,所以在此先感谢您的帮助!

I've poked around, and it sounds like I might need to pass in the path to Chrome(), but I'm not even sure if that is the issue or not. I'm definitely about as green as they come, so thanks in advance for any help!

推荐答案

听起来好像您没有通过远程调试端口启动Chrome.

Sounds like you haven't started Chrome with a remote debugging port.

找到chrome的路径并使用该标志-remote-debugging-port=9222

Find path to chrome and run with this flag -remote-debugging-port=9222

https://developer.mozilla.org/zh-CN /docs/Tools/Remote_Debugging/Chrome_Desktop

这篇关于在Windows的Linux子系统上无法从Selenium启动Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆