Questions tagged [pageobjects]

A design pattern to represent a web page as an object. Usually used in UI / end-to-end testing and browser automation.

A page object provides access to a web page. In its implementation, a page object typically makes use of a web driver like or . The page object hides the html and web driver details, and provides an abstract interface to the page in terms of its application domain.

The page objects are subsequently used to create end-to-end test scenarios that click through the application. The use of page objects make these tests easier to maintain when details of the underlying pages change.

This tag can be used for questions on the design, implementation, and use of page objects for end-to-end testing of web applications.

More information:

845 questions
65
votes
3 answers

Pythonic way to resolve circular import statements?

I just inherited some code which makes me uneasy: There is a testing library, full of classes corresponding to webpages on our site, and each webpage class has methods to automate the functionality on that page. There are methods to click the link…
Nathan
  • 4,545
  • 6
  • 32
  • 49
56
votes
2 answers

Codeception, write acceptance tests with the pageObject design pattern and gherkin

I'm looking for a simple example of code with the pageObject design pattern and gherkin because when I follow the codeception BDD documentation, all examples written in the tests/support/AcceptanceTester.php. I don't understand (poor English skills…
spacecodeur
  • 2,206
  • 7
  • 35
  • 71
42
votes
6 answers

page object model: why not include assertions in page methods?

First-time poster. I've been working in UI automation for many years, but was only recently introduced to/instructed to work with the Page Object Model. Most of it is common sense and includes techniques I've been using already, but there's a…
Jon Nelson
  • 421
  • 1
  • 4
  • 4
33
votes
2 answers

What is the Page Object Pattern in Selenium WebDriver?

What is page object pattern in Selenium WebDriver? What is the use of it and how can we use this in Selenium WebDriver? Example will be appreciated.
bugCracker
  • 3,656
  • 9
  • 37
  • 58
29
votes
3 answers

What's the best way to use Selenium PageObject Design Pattern

I'm creating tests using Selenium 2 Web Driver with C#.Net. After reading through a lot of the Selenium documentation, I am left still feeling unsure on how to go about testing using the PageObject design patterns. Many of the selenium examples are…
Patrick Magee
  • 2,951
  • 3
  • 33
  • 50
29
votes
5 answers

Is Page Object Model linking compatible with Cucumber's Gherkin?

With Test Automation's Page Object Model we link pages together like this: WebDriver driver = new WebDriver() HomePage homePage = new HomePage(driver); LoginPage loginPage = homePage.GoToLoginPage(); WelcomePage welcomePage =…
Charlie S
  • 4,366
  • 6
  • 59
  • 97
28
votes
7 answers

Get the By locator of an already found WebElement

Is there an elegant way to get the By locator of a Selenium WebElement, that I already found/identified? To be clear about the question: I want the "By locator" as used to find the element. I am in this case not interested in a specific attribute or…
drkthng
  • 6,651
  • 7
  • 33
  • 53
23
votes
6 answers

Page Object Model Best Practices in Selenium

When you are modelling your page objects, how would you deal with a page which has form and about 50 input fields on it? What is the best practice here? Would you create a page object and write a separate function for each input action? or would you…
Amir Ghahrai
  • 618
  • 1
  • 7
  • 22
17
votes
3 answers

StaleElementReference Exception in PageFactory

I am trying to learn the PageFactory model. I understood the fact that when we do a initElements, the WebElements are located. Say for example, I click on a webelement and because of which there is a change in one of the other webelements in DOM.…
17
votes
3 answers

Nested Page Objects in Protractor

The Question: What is the canonical way to define nested Page Objects in Protractor? Use Case: We have a complicated page that consists of multiple parts: a filter panel, a grid, a summary part, a control panel on a side. Putting all the element and…
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
15
votes
3 answers

Is Ruby compatible with strict Page Object Pattern?

I have built various Test Automation frameworks using the Page Object Pattern with Java (https://code.google.com/p/selenium/wiki/PageObjects). Two of the big benefits I have found are: 1) You can see what methods are available when you have an…
Charlie S
  • 4,366
  • 6
  • 59
  • 97
14
votes
2 answers

How to implement WebDriver PageObject methods that can return different PageObjects

I've just started using WebDriver, and I'm trying to learn the best practices, in particular using PageObjects and PageFactory. It's my understanding that PageObjects should expose the various operations on a web page, and isolate the WebDriver code…
James Bassett
  • 9,458
  • 4
  • 35
  • 68
13
votes
2 answers

Canonical way to define page objects in Protractor

We've been using the Page Object pattern for quite a while. It definitely helps to organize the end-to-end tests and makes tests more readable and clean. As Using Page Objects to Organize Tests Protractor documentation page shows us, we are defining…
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
13
votes
2 answers

Multiple browsers and the Page Object pattern

We are using the Page Object pattern to organize our internal AngularJS application tests. Here is an example page object we have: var LoginPage = function () { this.username = element(by.id("username")); this.password =…
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
11
votes
2 answers

Wait for element - WebDriver - PageObject pattern

As long as I use PageObject pattern I wondered where should I wait for element on dynamic pages. Assuming we have test method and pageObject class. Should I do something like (in test method): Click on button Wait for element to be displayed Verify…
Robert
  • 313
  • 1
  • 2
  • 8
1
2 3
56 57