Cypress Hello world

Precondition

Hello world test for PriceFx application

  1. open firstTest.cy.js on your local PC in the cloned repo

    • path: e2e-automation-repo\cypress\e2e\final

  2. use FElogin command like this: cy.FElogin('login')

    • this command is found in this file: e2e-automation-repo\cypress\support\commands.js

  3. save and run your test

  4. you should be logged in Price Fx application

image-20230327-131826.png
FElogin command
image-20230327-131929.png
cypress


  • now you can write your test.

  • command FElogin is needed to use in every test “it”, or you can add this FElogin command into beforeEach section and then it is not needed to use it in every “it”

image-20230327-132820.png
FElogin into beforeEach section

Tips & tricks

  • for creating a test without commands, use primary elements with data-attributes in html code

    • data-test-column

    • data-column-name

    • data-test

    • data-test-parent

    • …..

      image-20230327-133653.png


Example task for you:

//login

//go to Agreements & Promotions page

//click on button "New agreement & promotion"

solution
    //go to Agreements & Promotions page
    cy.visit('#/pm/contracts')
    cy.waitForSpinner()

    //click on button New agreement & promotion
    cy.get('[data-test="contract-new-button"]').click()
    cy.waitForSpinner()
image-20230327-135050.png



  • for waiting use prepared command: cy.waitForSpinner()

    • command is located in e2e-automation-repo\cypress\support\commands.js file

    • command waits, till running circle disappears and page is loaded

    • image-20230327-135523.png


  • for data manipulation use API commands

    • in the file: e2e-automation-repo\cypress\support\externalCommands_API.js

    • you can find prepared API commands with.

    • read comments in the code for better understanding

      image-20230327-134057.png
      externalCommandsAPI.js file
      image-20230327-134201.png
      Cypress test for with using API command for inserting data into CP table


  • for common action use prepared FE commands

    • in the support folder, there are plenty of prepared commands for easier cypress implementation

    • before you will start to do some test, make a little research, if we haven’t had it already prepared as a command


Happy testing with Cypress.