Centos 在 Selenium 使用中的异常:chrome not reachable

在使用 Selenium 进行数据处理的过程中,发现了一些问题:

selenium.common.exceptions.WebDriverException: Message: chrome not reachable

 WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist

首先确认我们的 ChromeDriver 和已经安装的 Chromium 的版本匹配没有问题

chromium-browser --version
Chromium 90.0.4430.212 Fedora Project
../../driver/chromedriver --version
ChromeDriver 89.0.4389.23 (61b08ee2c50024bab004e48d2b1b083cdbdac579-refs/branch-heads/4389@{#294})

但是,之后发现问题依然存在。

经历了大量的调查,应该是上次使用 webdriver 的时候,没有关闭浏览器,所以

[root@iz8vb7tuq6sw9mx44vk7p6z ~]# ps aux | grep Chrome
root     18561  0.0  0.0 112812   976 pts/5    R+   08:26   0:00 grep --color=auto Chrome
scrapy   19401  0.0  1.7 34313044 17356 pts/2  Sl   Nov02   0:12 /usr/bin/chromium-browser --enable-plugins --enable-extensions --enable-user-scripts --enable-printing --enable-gpu-rasterization --enable-sync --auto-ssl-client-auth --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --headless --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.bV7kKM data:,
scrapy   19671  0.0  1.3 34300716 13676 pts/2  Sl   Nov02   0:11 /usr/bin/chromium-browser --enable-plugins --enable-extensions --enable-user-scripts --enable-printing --enable-gpu-rasterization --enable-sync --auto-ssl-client-auth --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --headless --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.nm1tQ1 data:,
scrapy   31991  0.0  1.3 34300716 13328 pts/2  Sl   Nov02   0:10 /usr/bin/chromium-browser --enable-plugins --enable-extensions --enable-user-scripts --enable-printing --enable-gpu-rasterization --enable-sync --auto-ssl-client-auth --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-dev-shm-usage --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --headless --log-level=0 --no-first-run --no-sandbox --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.E71n9Z data:,

这里发现我们有3个 chromium 浏览器在运行,所以我们找到他们的 PID 并将他们一一关闭。

kill -9 PID

重新打开代码,就没有问题了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值