TreeItem `getActionButton` results in a `TypeError: Cannot read properties of null (reading 'indexOf')`
tylor-metrics opened this issue · comments
I have run into an issue, not 100% sure that I have identified the root cause correctly yet though, so this may be a red-herring.
However, this change did help me move forward.
The getActionButton
function in the TreeItem
class in pageObjects/sidebar/viewItem.js
appears to throw because it is unable to find an action Button.
Current:
async getActionButton(label) {
const actions = await this.getActionButtons()
if (actions.length > 0) {
return actions.find((item) => item.getLabel().indexOf(label) > -1)
}
return undefined
}
Suggested Change:
async getActionButton(label) {
const actions = await this.getActionButtons()
if (actions.length > 0) {
for (let item of actions) {
let itemLabel = await item.getLabel() ?? await item.elem.getAttribute('aria-label');
if (itemLabel.indexOf(label) > -1) {
return item;
}
}
}
return undefined;
}
This basically, checks both the label
and the aria-label
.
However, that begs the question, why (in my case) is it not finding the button by label currently? I am still not sure yet.
This is what the DOM ends up looking like. The label
prop passed to getActionButton(label)
is the text in the aria-label such as Action Item 1
or Action Item 2
.
@tylor-metrics thanks for the fix. Please confirm if the change fixes the issue.
Closing due to inactivity.