-
Notifications
You must be signed in to change notification settings - Fork 368
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: [M3-8914] - POC: Centralized Locators for Linode Page in Cypress UI Automation Framework #11594
test: [M3-8914] - POC: Centralized Locators for Linode Page in Cypress UI Automation Framework #11594
Conversation
… UI Automation Framework
…//github.com/subsingh-akamai/manager into M3-8914-cypress-poc-centralized-locators-new
Hi @bnussman and @jdamore-linode - I have created this new PR for POC of centralized locators and added you as reviewer (PR #11455). |
Coverage Report: ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you! confirmed tests passed ✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Subodh! This is a nice improvement since I last looked at #11455, and I think serves as a good demonstration and starting point to explore this pattern.
I'm still not totally sold on the DX aspect of this change, namely some of the things we've already discussed in the previous PR:
- I still wonder if discoverability of these locators is an issue and whether development velocity is improved or hindered as a result. My instinct is that locators could hinder test development and test troubleshooting because of the extra overhead of having to manage/find these locators and relate them to test failure messages
- What problem are we solving with these that isn't solved by the
ui
helper objects? When should we lean for these rather than UI helpers? My instinct is that if we're using certain selectors so often throughout the tests that we feel the need to do something about it, a UI helper would be a good choice. And if we're using selectors here and there without a lot of repetition, do we really want to bother with factoring those out?
I think this is a good starting point and that we can merge this and see how it impacts DX, but I think our next steps should be to explore writing new tests using locators to see what that's like from a development and review point of view 👍
// Top menu items | ||
export const topMenuItemsLocator = { | ||
// Create Button | ||
addNewMenuButton: '[data-qa-add-new-menu-button="true"]', | ||
// Notifications Button | ||
notificationsButton: '[aria-label="Notifications"]', | ||
// Search Icon | ||
searchIcon: '[data-qa-search-icon="true"]', | ||
// Search Text Field | ||
searchInput: '[data-qa-main-search]', | ||
// Toogle side menu bar button | ||
toggleSideMenuButton: '[aria-label="open menu"]', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Top menu items | |
export const topMenuItemsLocator = { | |
// Create Button | |
addNewMenuButton: '[data-qa-add-new-menu-button="true"]', | |
// Notifications Button | |
notificationsButton: '[aria-label="Notifications"]', | |
// Search Icon | |
searchIcon: '[data-qa-search-icon="true"]', | |
// Search Text Field | |
searchInput: '[data-qa-main-search]', | |
// Toogle side menu bar button | |
toggleSideMenuButton: '[aria-label="open menu"]', | |
}; | |
/** Top menu items. */ | |
export const topMenuItemsLocator = { | |
/** Top menu create button. */ | |
addNewMenuButton: '[data-qa-add-new-menu-button="true"]', | |
/** Top menu notifications button. */ | |
notificationsButton: '[aria-label="Notifications"]', | |
/** Top menu search icon. */ | |
searchIcon: '[data-qa-search-icon="true"]', | |
/** Top menu search field. */ | |
searchInput: '[data-qa-main-search]', | |
/** Top menu navigation toggle. */ | |
toggleSideMenuButton: '[aria-label="open menu"]', | |
}; |
We can get a nice DX enhancement by using doc comments for these objects and properties, which might be good for discoverability:
Before | After |
---|---|
![]() |
![]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you suggessting doc comments, I have added same in this commit 793d6d6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, UI helpers primarily focus on element interactions, such as buttons.ts and drawer.ts, which is great for implementing generic element interactions.
However, this POC was specifically aimed at centralizing locators to prevent defining them across multiple tests.
Ideally, test-specific DOM locators should be maintained in a centralized location to enhance reusability across tests, ultimately reducing development effort in the long run.
I completely agree that discoverability of these locators remains a challenge due to Cypress error traces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @subsingh-akamai !
Code Review ✅
All Test Passed ✅
Cloud Manager UI test results🔺 2 failing tests on test run #4 ↗︎
Details
TroubleshootingUse this command to re-run the failing tests: yarn cy:run -s "cypress/e2e/core/kubernetes/lke-create.spec.ts" |
Description 📝
The objective of this proof of concept (PoC) task is to enhance the UI automation framework in Cypress by implementing centralized locators for the Linode page. This will involve:
Note - This is a new PR for #11455.
Below are guidelines which is proposed to use centralized locators
findByText()
,findByTitle()
,findByLabel()
,findByTestId()
.findByText()
,findByTitle()
,findByLabel()
, orfindByTestId()
.Changes 🔄
As part of POC, I have updated of locators in test cypress/e2e/core/linodes/smoke-linode-landing-table.spec.ts
Below 2 files are created under cypress/support/ui/locators to store locators used in above test
How to test 🧪
yarn cy:run -s cypress/e2e/core/linodes/smoke-linode-landing-table.spec.ts
Verification steps
When test executed using this command
yarn cy:run -s cypress/e2e/core/linodes/smoke-linode-landing-table.spec.ts
all tests should pass successfully.As an Author, to speed up the review process, I considered 🤔
👀 Doing a self review
❔ Our contribution guidelines
➕ Adding a changeset
🔐 Removing all sensitive information from the code and PR description