小编Cyp*_*uto的帖子

当 JSON 夹具文件中有多个记录时,如何将 cy.fixture 与 Array 一起使用

\在其中创建了一个 Cypress Testscript 并设置为在循环中执行,因为想要在夹具 json 中使用多组测试数据执行。如果您向下并看到 cy.fixture 仅适用于第一个条目,并且测试使用 json 中的第一个条目执行两次(测试数据文件)关于如何包含数组迭代和夹具的任何帮助都会有所帮助

var Launchindex = 0;
for (Launchindex = 0; Launchindex  < 2; Launchindex ++) {

describe('Launch  testsite',() => {

    it('try login using testdata', () => {

        cy.visit('https://xyzz')
        cy.title().should('contain','title check')
    })

    it('check url', () => {

        cy.url().should('contain','xyz')

    })

    it('enter details and submit', () => { 
        //Fixture loads the testdata setup in fixtures folder , so setup testdata required before executing test script   



        cy.fixture('testdata').then(testdata  => {

            const ModuleID = testdata[0].ModuleID 
            const LoginName = …
Run Code Online (Sandbox Code Playgroud)

cypress

3
推荐指数
1
解决办法
2755
查看次数

标签 统计

cypress ×1