我使用的 synbtax 运行我的测试。我看到的问题是我的组织有阻止 chrome headed 测试运行的扩展。这些测试使用 chrome 运行平滑无头,但在使用 chrome 运行时被阻止。我想知道是否有一种方法可以使用隐身运行 chrome headed。
npx cypress run--browser chrome--headed
在 cypress\ plugins\ index.js 文件中放置以下代码:
module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, launchOptions) => {
if (browser.family === 'chromium' && browser.name !== 'electron') {
launchOptions.args.push("--incognito");
return launchOptions
}
if (browser.name === 'electron') {
launchOptions.preferences.incognito = true
return launchOptions
}
})
}
我已经使用了柏树,并且在隐身模式下运行了柏树测试运行器。您需要做的就是在柏树的 plugins 文件夹中的 index.js 文件中提供以下代码。
module.exports = (on, config) => {
on("before:browser:launch", (browser, launchOptions) => {
console.log(launchOptions.args);
if (browser.name === "chrome") {
launchOptions.args.push("--incognito");
}
return launchOptions;
});
};
相同的参考:https://docs.cypress.io/guides/references/migration-guide#Plugin-Event-before-browser-launch
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(2条)