Skip to content
CodeKruPro

Build a small page object in Python

Automation taskMediumPython onlyAsked in: Accenture, Infosys, TCS, Wipro

Interviewers ask: "What is the Page Object Model? Show me a page class." In this task you fill in one method of a small page object and call it from the script. That is the core of the pattern: the locators live inside the class, and the script calls a readable method.

Build a One-File Page Object

Build a One-File Page Object

A page object keeps the locators in methods. This file holds one small class. The method in the starter only returns an empty string.

Task:

  1. Fill in the method so it returns the h2 text
  2. Open Text Fields
  3. Print the heading from the page object

Print the lines below exactly.

Expected output:

Heading: Text Fields