【问题标题】:How to disable chromeWebSecurity in a certain test suite, in cypress如何在赛普拉斯的某个测试套件中禁用 chromeWebSecurity
【发布时间】:2021-06-28 11:56:53
【问题描述】:

我正在使用 cypress,我想在测试用例中禁用 chromeWebSecurity,但不想更改 cypress 配置。

在每个之前:

beforeEach('before test', () => {
        Cypress.config('chromeWebSecurity',false);
        cy.createUser('type').then((response) => {
            ssoId = response.id;
            phone = response.phone;
        });
    });

如果我在 cypress 配置 (cypress.json) 中添加 ""chromeWebSecurity": false" - 它可以工作,但我不想在我的所有测试套件中禁用它。

我正在尝试添加“Cypress.config('chromeWebSecurity',false);”在 "cy.createUser('type').then((response) => {" 之前在每个这样的之前:

beforeEach('before test', () => {
        Cypress.config('chromeWebSecurity',false);
        cy.createUser('type').then((response) => {
            ssoId = response.id;
            phone = response.phone;
        });
    });

但它不起作用

【问题讨论】:

标签: automated-tests cypress


【解决方案1】:

根据cypress docs,您可以将其作为选项添加到describeit

describe(
    'login',
    {
        chromeWebSecurity: true
    },
    () => {
        it('With webSecurity', () => {
            // ...
        })

        it('Without webSecurity',
            {chromeWebSecurity: false},
            () => {
            //...
            }
        )
    }
)

【讨论】:

  • chromeWebSecurity 不在您可以更改的选项列表中
猜你喜欢
  • 2023-02-14
  • 1970-01-01
  • 2023-02-18
  • 1970-01-01
  • 2021-11-06
  • 1970-01-01
  • 2021-10-20
  • 2020-05-16
  • 1970-01-01
相关资源
最近更新 更多