简体   繁体   中英

Cypress Cucumber Step running multiple steps

Lets say I have

Step1

Step2

Step3

Is it possible to have Step4 which runs all 3 of them?


Updated what I mean is

I already wrote 3 steps

Given('do step1', function () {})

Given('do step2', function () {})

Given('do step3', function () {})

Is it possible to have

Given('do step4', function () {
    do step1
    do step2
    do step3
})

If you write those 3 steps as individual functions you'll be able to achieve the same effect as what you're looking for:

login(user, pass){
   cy.visit(loginUrl)
   cy.get('#username').type(user)
   cy.get('#password').type(pass)
   return cy.contains('Submit').click()
}

stepTwo(){
   ... // Other stuff
}

stepThree(){
   ... // More stuff
}

Given('I log in as {string} with password {string}', function (username, password) {
   return login(username, password)
})

Given('some set up step', function () {
   login('bill.s.preston@wyldstallyns.com', 'bodacious')
   return stepTwo()
})

Given('another set up step', function () {
   login('theodore.logan@wyldstallyns.com', 'triumphant')
   stepTwo()
   return stepThree()
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM