Skip to content

[🐛 Bug]: XPath chaining not working in V9 in methods but same code working in v7 #14675

@PavanShasam

Description

@PavanShasam

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.18.4

Node.js Version

24

Mode

Standalone Mode

Which capabilities are you using?

What happened?

XPath chaining from the page objects files when specified in a method is not recognisable.
Ex: declare a locator get sampleLocator(){return $(‘//div/input’)}
Try chaining the same in a method using sibling like: cont actual = await this.sampleLocator.$(‘./following-sibling::div’)
waitfordisplayed(actual)
Seems like wdio9 unable to recognise the chained part when executed, but wdio7 has no issues and working absolutely fine.
So the workaround I have used is to add browser.execute

async randomFunction(title) {
return (await utils.getElementHtmlText(await this.randomMethod(title).$('./following-sibling::div[contains(@Class,"fakeLocator")]'))).replace(/\n/g, " ");
}

This above method execution will fail, as the './following-sibling::div[contains(@Class,"fakeLocator")]' is not displayed error will come

What is your expected behavior?

No response

How to reproduce the bug.

Create chaining xpath from methods in page object file using wdio9

Relevant log output

Element not displayed

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛help wantedIssues that are free to take by anyone interested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions