Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Page Object Model Purpose
00:00
5 left

Page Object Model Purpose

MediumPython

Problem

What is the Page Object Model (POM) and why is it used in test automation?

Implement resolve_test_steps(page_objects, steps) to demonstrate the separation between logical test actions and UI selectors. Each page object contains selectors and may inherit elements from a parent page.

Input: A map of page names to page definitions, and an ordered array of actions containing page, element, action, and an optional value. Supported actions are click, type, and select.

Output: Return one result per action, resolving inherited selectors. Return a successful result with the selector, or an error result for an unknown page, unknown element, or unsupported action.

Constraints: page inheritance is acyclic; child elements override parent elements.

Constraints

  • 1 <= number of page objects <= 1000
  • 1 <= number of test steps <= 10000
  • Each page definition contains an optional parent and an element-to-selector map
  • Page inheritance is acyclic
  • Supported actions are click, type, and select
  • Child elements override selectors inherited from a parent

Function Signature

def resolve_test_steps(page_objects, steps):
Interviewer

Your question is Page Object Model Purpose. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.