我通常在 chrome 浏览器作为基础平台上运行测试。有时我会在本地的 Firefox 和 MS Edge 浏览器上进行跨浏览器测试。配置到管道后,我运行了跨浏览器测试,但我的 MS Edge 浏览器无法正确安装浏览器,如下
错误:browserType.launch:在 C:\Users fs-build\AppData\Local\Microsoft\Edge\Application\msedge.exe 中找不到 Chromium 发行版“msedge” 运行“npx playwright install msedge”。
在执行文件中添加安装cmd后,我收到错误:
下载 Microsoft Edge 使用“2”个参数调用“DownloadFile”时出现异常:“请求已中止:无法创建 SSL/TLS 安全 渠道。” 在 C:gent2_work\s ode_modules\playwright-core 中 einstall_msedge_stable_win.ps1:8 字符:1
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : WebException
安装浏览器失败 错误:安装 msedge 失败
根据错误消息,在您的环境中,PowerShell 在默认情况下连接到网站时似乎使用 TLS 1.0,但您发出请求的网站需要 TLS 1.1 或 TLS 1.2 或 SSLv3。
要解决该错误,只需尝试使用
SecurityProtocol
属性来指定支持所有协议。
只需在脚本顶部或安装 cmd 之前添加以下内容,然后重试。
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy