selenium-standalone 安装时,无法下载 chromedriver,怎么办?

2020-05-22 23:00:23 +08:00
 yazoox

windows10

运行 "node_modules.bin\selenium-standalone.cmd install".

然后就卡住了,接着报错如下

node_modules\.bin\selenium-standalone.cmd install
...

Error: Could not download https://chromedriver.storage.googleapis.com/2.43/chromedriver_win32.zip: Error: read ECONNRESET

googleapis.com 这个地址,我们都知道,被墙的。

但是我在 IE 的 proxy server 设置里面,挂了代理。并且能够用 IE 打开油管。

这个设置对 windows command 不起作用么?

那怎么样才可以安装这些 driver 呢?

1671 次点击
所在节点    问与答
7 条回复
icyluna
2020-05-23 01:29:26 +08:00
seki
2020-05-23 02:17:11 +08:00
有一个 npm/环境 变量可以用来配置下载的地址
wwqgtxx
2020-05-23 08:07:33 +08:00
set http_proxy 和 set https_proxy 这两个环境变量
yazoox
2020-05-23 09:50:49 +08:00
@seki 这个手工下载没有用吧。就算手工下载了,拷贝到目标目录,也不能完成 selenium 的安装啊?

@icyluna 我的.npmrc 里面,已经设置了
`registry=https://registry.npm.taobao.org/`

但这个安装,好像和 npm 没有关系吧?是直接调用的 selenium 的 script/cmd

@wwqgtxx 兄弟,我试着按你的方法设置。
```
set http_proxy=http://127.0.0.1:1080
set https_proxy=https://127.0.0.1:1080
```

我本地 v2r**的 client 已经打开,监听的就是 127.0.0.1:1080 。已经用 chrome 确认 v2r**正常工作了。

但是还是不成功呢,报错如下:

```
Error: Could not download https://chromedriver.storage.googleapis.com/2.43/chromedriver_win32.zip: Error: tunneling socket could not be established, cause=Client network socket disconnected before secure TLS connection was established
```
yazoox
2020-05-23 10:27:36 +08:00
@wwqgtxx
试了一下 环境变量

set http_proxy=socks5://127.0.0.1:1080
set https_proxy=socks5://127.0.0.1:1080

或者
.npmrc 设置
http-proxy=socks5://127.0.0.1:1080
https-proxy=socks5://127.0.0.1:1080

均不行。报错类似
```
Error: Could not download chromedriver_win32.zip: Error: tunneling socket could not be established, cause=socket hang up
```

但我使用
```
curl <https:>//chromedriver.storage.googleapis.com/2.43/chromedriver_win32.zip -O
```

能够成功下载(通过代理)

p.s. V2EX 不让我输入外链地址。
yazoox
2020-05-23 12:05:38 +08:00
尝试使用
```
selenium-standalone install --version=3.141 --baseURL=<http>://npm.taobao.org/mirrors/selenium
selenium-standalone install --drivers.chrome.version=2.43 --drivers.chrome.baseURL=<https>://npm.taobao.org/mirrors/chromedriver
```

指定 mirror 安装,可是报错提示,还是
```
Error: Could not download <https>://chromedriver.storage.googleapis.com/2.43/chromedriver_win32.zip: Error: tunneling socket could not be established, cause=write EPROTO 16132:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:
```
yazoox
2020-05-23 12:46:29 +08:00
Resolved the issue.

用的 v2xx 的代理,本地有一个 v2xx 客户端,打开 HTTP 代理,全局模式。
去 IE 里面查看网络设置,发现端口不是 v2xx 的 1080,而是 1081 (所以前面一直失败)
于是,windows command line 环境变量设置

set HTTPS_PROXY=http://127.0.0.1:1081
set HTTP_PROXY=http://127.0.0.1:1081

然后,再运行 selenium-standalone install 就能够成功下载安装各个 drivers 了。

打扰大家了。

谢谢!

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/674532

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX