Cypress设置chrome浏览器运行自启动开发者工具

在plugins-》index.js文件末尾加上这一块代码,更详细的内容查看文档中的plugins相关内容 https://docs.cypress.io/api/plugins/browser-launch-api#Syntax

 

 

 

module.exports = (on, config) => {
    on('before:browser:launch', (browser = {}, launchOptions) => {
        // `args` is an array of all the arguments that will
        // be passed to browsers when it launches
        console.log(launchOptions.args) // print all current args

        if (browser.family === 'chromium' && browser.name !== 'electron') {
            // auto open devtools
            launchOptions.args.push('--auto-open-devtools-for-tabs')
        }

        if (browser.family === 'firefox') {
            // auto open devtools
            launchOptions.args.push('-devtools')
        }

        if (browser.name === 'electron') {
            // auto open devtools
            launchOptions.preferences.devTools = true
        }

        // whatever you return here becomes the launchOptions
        return launchOptions
    })
};

 

posted @ 2022-04-13 18:53  陈晓猛  阅读(210)  评论(0编辑  收藏  举报