Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(pom): cross-page chaining of page objects #27155

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open

Conversation

dbrans
Copy link
Contributor

@dbrans dbrans commented Sep 15, 2024

Description

Introduce chaining across pages objects in order to build-out in future tests.

Prior art: https://test-automation.blog/selenium/method-chaining-page-object-model/

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@dbrans dbrans requested a review from a team as a code owner September 15, 2024 20:22
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@github-actions github-actions bot added the team-transactions Transactions team label Sep 15, 2024
Copy link

sonarcloud bot commented Sep 15, 2024

@chloeYue
Copy link
Contributor

Thanks for the implementation @dbrans . I can see a lot of improvement, though I still have one comment:
We try to keep page objects and flows isolated from each other, which means we want to avoid one page returning an instance of another page or one flow/page method taking a page instance as a parameter. The reason for this is to avoid circular references and simplify the usage.
In the case of complex workflows where several pages are involved, we perform each function on the corresponding page. Then, when we move to the next page, we create an instance for this new page and start using methods for this new page. This way, users don't need to think a lot about the pages, they just need to create instances and use the methods.


export const getApp = (driver: Driver): App => {
return new App(driver);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we really need to add this class. For the getHeaderNavbar() and getLoginPage() methods, we can create an instance of HeaderNavbar() or LoginPage() directly when we need them. For the openSettings(), we can do new HeaderNavbar(this.driver).openSettings() in tests. For the login method, I think the original loginWithBalanceValidation is more straightforward and efficient enough.
As page object model is in the adoption phase, we are trying to keep it as simple as possible to facilitate easier onboarding and usage.

@MARAIS4455
Copy link

MARAIS4455 commented Sep 16, 2024 via email

async scrollToAndClickElement(locator) {
const element = await this.findElement(locator);
await this.scrollToElement(element);
await this.clickElement(element);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m so lost it’s sad, this is new and from my cell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-transactions Transactions team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants