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

TreeItem getActionButton results in a TypeError: Cannot read properties of null (reading 'indexOf') #121

Closed
tylor-metrics opened this issue Jun 12, 2024 · 2 comments

Comments

@tylor-metrics
Copy link
Contributor

tylor-metrics commented Jun 12, 2024

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.

Screenshot 2024-06-12 at 10 57 32 AM

@christian-bromann
Copy link
Contributor

@tylor-metrics thanks for the fix. Please confirm if the change fixes the issue.

@christian-bromann
Copy link
Contributor

Closing due to inactivity.

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

No branches or pull requests

2 participants