Skip to content

Conversation

@surajrdy-aws
Copy link

Problem

We were faced with the problem that when all our tests and helpers were merged together, and then run as a full suite, we saw errors with the pinContext.test.ts file. Namely, it was targeting a background overlay that had identical css components to the pinContext overlay. This is problematic since our entire suite relies on these css components, and even test-ids were not differentiated. Additionally, our pinContextHelpers used sleep functions in the range of 100-3000 ms which is naturally arbitrary values.

Solution

We implement the XPath css selectors that are used within Selenium to identify the pinContext Buttons by text, not css classes or ids. This drastically decreases the length and complexity of our helpers while also eliminating the need for sleep functions other than a sleep(0) function for subMenuItems that is needed for the DOM to be loaded. Below is our success of the tests:

Screenshot 2025-08-19 at 1 49 34 PM
  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@surajrdy-aws surajrdy-aws requested a review from a team as a code owner August 19, 2025 17:52
@github-actions
Copy link

  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

for (const item of menuListItems) {
const textWrapper = await item.findElement(
By.css('.mynah-detailed-list-item-text.mynah-detailed-list-item-text-direction-row')
await sleep(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is needed, but maybe it worth adding a comment about why?

Copy link
Author

Choose a reason for hiding this comment

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

Ah yes, good thought.

const item = await waitForElement(
webview,
By.xpath(
`//div[contains(@class, 'mynah-detailed-list-item') and contains(@class, 'mynah-ui-clickable-item')]//div[contains(@class, 'mynah-detailed-list-item-name') and text()='${itemName}']`
Copy link
Contributor

Choose a reason for hiding this comment

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

these strings are gnarly, how does one find this? Are they querying the css based on these attributes?

Copy link
Author

@surajrdy-aws surajrdy-aws Aug 19, 2025

Choose a reason for hiding this comment

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

Yeah I think they are pretty complex, but I do think this is the best/reliable way to snipe the correct element. Yup, XPath is querying based on the css class attributes. I think in general we can use css selectors, but for this specific instance it may be best to use our XPath. You could find this by using the printElementHTML Function and dumping the entire overlay to figure out what you need if building/debugging a XPath selector.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wow cool! Maybe in the future we can build/find a nicer interface on top of these queries? This looks good for now though, nice find!

Copy link
Author

Choose a reason for hiding this comment

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

Yeah I agree, I think building a helper function for XPaths could be useful, I think it has a lot of moving parameters but definitely doable.

@surajrdy-aws
Copy link
Author

/retryBuilds

await clickPinContextButton(webviewView)
await clickPinContextMenuItem(webviewView, 'Files')
await clickPinContextMenuItem(webviewView, 'Active file')
await clickSubMenuItem(webviewView, 'Active file')

Choose a reason for hiding this comment

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

does the File test work properly now? or do we still have to skip it?

Copy link

@laura-codess laura-codess left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@bywang56 bywang56 merged commit 1e78ac7 into aws:feature/ui-e2e-tests Aug 19, 2025
27 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants