I have 2 tests:
First:
Login-> Go to page A-> click on a checkbox A -> click on button A – >do an action.
Second:
Login -> Go to page A-> click on a checkbox A -> click on Button B -> do an action.
Since Login, Go to page A and click on checkbox A are identical steps..
IS there a way i can write these two tests in the same command instead of writing two different commands.
Thank you
2
Answers
You can use Cypress’
beforeEach()
functionality to execute a set of commands before each test runs.This is most useful when running the same tests in a shared
describe
orcontext
block.If your tests will be in separate
describe
/context
blocks or in separate spec files, you may want to consider creating a Cypress custom command to be re-used in different files.The command can take parameters to change it’s test sequence as required.
With parameters you can compose the command to suit different parts of the test.