首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cypress: Cypress找不到边缘

Cypress: Cypress找不到边缘
EN

Stack Overflow用户
提问于 2020-09-04 22:13:20
回答 1查看 120关注 0票数 1

我的机器上安装了Cypress 5.0和Edge v84。当我跑的时候

代码语言:javascript
复制
> npx cypress open

然后设置调试器模式

代码语言:javascript
复制
> set DEBUG=cypress:launcher

Cypress正在尝试在以下位置使用edge

代码语言:javascript
复制
     cypress:launcher looking at possible paths... { browser: { name: 'edge', family: 'chromium', channel: 'stable', displayName: 'Edge', versionRegex: /Microsoft Edge (\S+)/m, binary: 'edge' }, exePaths: [ 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe' ] } +0ms
  cypress:launcher found C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe ? false +1ms

      cypress:launcher looking at possible paths... { browser: { name: 'edge', family: 'chromium', channel: 'canary', displayName: 'Edge Canary', versionRegex: /Microsoft Edge Canary (\S+)/m, binary: 'edge-canary' }, exePaths: [ 'C:\\Users\\muthu\\AppData\\Local\\Microsoft\\Edge SxS\\Application\\msedge.exe' ] } +0ms
  cypress:launcher found C:\Users\muthu\AppData\Local\Microsoft\Edge SxS\Application\msedge.exe ? false +1ms

      cypress:launcher looking at possible paths... { browser: { name: 'edge', family: 'chromium', channel: 'beta', displayName: 'Edge Beta', versionRegex: /Microsoft Edge Beta (\S+)/m, binary: 'edge-beta' }, exePaths: [ 'C:\\Program Files (x86)\\Microsoft\\Edge Beta\\Application\\msedge.exe' ] } +0ms
  cypress:launcher found C:\Program Files (x86)\Microsoft\Edge Beta\Application\msedge.exe ? false +1ms

    cypress:launcher looking at possible paths... { browser: { name: 'edge', family: 'chromium', channel: 'dev', displayName: 'Edge Dev', versionRegex: /Microsoft Edge Dev (\S+)/m, binary: 'edge-dev' }, exePaths: [ 'C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe' ] } +0ms
  cypress:launcher found C:\Program Files (x86)\Microsoft\Edge Dev\Application\msedge.exe ? false +1ms

但是边缘安装在不同的位置- C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe

如何获取Cypress identify Edge?

EN

回答 1

Stack Overflow用户

发布于 2021-09-07 02:23:29

如果安装在其他位置,则可以在以下路径中手动添加

代码语言:javascript
复制
cypress/plugins/index.js

您需要将以下代码

代码语言:javascript
复制
const execa = require('execa')
const findBrowser = () => {
  
  const browserPath = {Browser Path Location}

  return execa(browserPath, ['--version']).then((result) => {
    const [, version] = /Edge Browser (\d+\.\d+\.\d+\.\d+)/.exec(result.stdout)
    const majorVersion = parseInt(version.split('.')[0])

    return {
      name: 'Edge',
      channel: 'stable',
      family: 'chromium',
      displayName: 'Edge',
      version,
      path: browserPath,
      majorVersion,
    }
  })
}

module.exports = (on, config) => {
  return findBrowser().then((browser) => {
    return {
      browsers: config.browsers.concat(browser),
    }
  })
}

参考:https://docs.cypress.io/guides/guides/launching-browsers#Customize-available-browsers

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63742856

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档