End To End Test Script Writing

 E2E for Beginner

  • Command to run e2e - ng e2e
  • Command to run the angular app - ng serve

Page Objects of E2E

Elements capturing needs to move into page objects. So page objects suppose to identify components of a page. And then e2e needs to do the action, verification and so on

Elements of Page Object

  • use element finder as a constructor
  • Create a class
  • Create functions inside the class
Ex :  


Add wait until items are loaded

Ex:  private readonly matListItemSelector = '.list-item';

  • Add function


  • Use it in script

  • Verify all items display with a single item in a list
Ex: 


Element Identification

Heading

 async getHeading(): Promise<string> {
    return this.elementFinder.element(by.css('h1')).getText();
  }

async functions :

Even though these functions are failed the script is executed next steps

Promise<string>

use the correct return type

  • Identify components from a list


ElementArrayFinder

Use an array to pass the values. Then using an index select the required value

  • Buttons


Use by.buttonText or by.class
  • Input box

Script

Use element finder in test script



Add scope of each page object


  • Verification of values



  • Button click


  • Use await browser.waitForAngular();
until load web elements

Search by adding values and select one option from the list


  • Verify the value of a list


Comments

Post a Comment