You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(amazonq): XPath Selector for pinContextHelpers and fixing PinContext ability to run in full test suite (#7928)
## 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:
<img width="313" height="77" alt="Screenshot 2025-08-19 at 1 49 34 PM"
src="https://github.com/user-attachments/assets/dd378c02-67c1-4f73-a6e7-cd709e028c80"
/>
---
- 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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
console.log(`Clicking Pin Context menu item: ${itemName}`)
79
-
awaititem.click()
80
-
return
81
-
}
82
-
}
83
-
84
-
thrownewError(`Pin Context menu item not found: ${itemName}`)
67
+
constitem=awaitwaitForElement(
68
+
webview,
69
+
By.xpath(
70
+
`//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}']`
71
+
)
72
+
)
73
+
console.log(`Clicking Pin Context menu item: ${itemName}`)
74
+
awaititem.click()
85
75
}
86
76
/**
87
77
* Lists all the possible Sub-menu items in the console.
88
78
* @param webview The WebviewView instance
89
79
* @returns Promise<boolean> Returns the items as a WebElement List and the labels in a string array
// We require a sleep function of 0 so that the DOM of the SubMenu can load correctly.
110
+
awaitsleep(0)
111
+
constitem=awaitwaitForElement(
112
+
webview,
113
+
By.xpath(
114
+
`//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}']`
0 commit comments