webdriverio / webdriverio

Next-gen browser and mobile automation test framework for Node.js
http://webdriver.io
MIT License
9k stars 2.49k forks source link

[🐛 Bug]: Using $("..") in chained elements not working #13652

Open SimonRazor opened 1 day ago

SimonRazor commented 1 day ago

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

20.11.1

Mode

WDIO Testrunner

Which capabilities are you using?

browserName: 'chrome',
browserVersion: 'stable',

What happened?

In v9 when trying to traverse the DOM using chained element and Xpath expressions it can't find the element. Changing back to v8 works as expected.

Error: Can't call $ on element with selector ".." because element wasn't found Error: Can't call $ on element with selector ".." because element wasn't found at implicitWait (C:\Users\Test\Projects\Test\node_modules\webdriverio\build\index.js:49:13) at async Element.elementErrorHandlerCallbackFn (C:\Users\Test\Projects\Test\node_modules\webdriverio\build\index.js:6674:23) at async Element.wrapCommandFn (C:\Users\Test\Projects\Test\node_modules\@wdio\utils\build\index.js:1368:23) at async Element.wrapCommandFn (C:\Users\Test\Projects\Test\node_modules\@wdio\utils\build\index.js:1368:23) at async Context. (C:\Users\Test\Projects\Test\test\specs\test.spec.ts:4:28) at async Context.executeAsync (C:\Users\Test\Projects\Test\node_modules\@wdio\utils\build\index.js:1488:20) at async Context.testFrameworkFnWrapper (C:\Users\Test\Projects\Test\node_modules\@wdio\utils\build\index.js:1559:14)

What is your expected behavior?

No response

How to reproduce the bug.

describe('Chaining', () => {
    it('should be true', async () => {
        await browser.url("https://the-internet.herokuapp.com/challenging_dom");
        console.log(await (await $("td=Adipisci1").$("..").$("a=edit")).isDisplayed());
    });
});

Relevant log output

Error:
Can't call $ on element with selector ".." because element wasn't found
Error: Can't call $ on element with selector ".." because element wasn't found
    at implicitWait (C:\Users\Test\Projects\Test\node_modules\webdriverio\build\index.js:49:13)
    at async Element.elementErrorHandlerCallbackFn (C:\Users\Test\Projects\Test\node_modules\webdriverio\build\index.js:6674:23)
    at async Element.wrapCommandFn (C:\Users\Test\Projects\Test\node_modules\@wdio\utils\build\index.js:1368:23)
    at async Element.wrapCommandFn (C:\Users\Test\Projects\Test\node_modules\@wdio\utils\build\index.js:1368:23)
    at async Context.<anonymous> (C:\Users\Test\Projects\Test\test\specs\test.spec.ts:4:28)
    at async Context.executeAsync (C:\Users\Test\Projects\Test\node_modules\@wdio\utils\build\index.js:1488:20)
    at async Context.testFrameworkFnWrapper (C:\Users\Test\Projects\Test\node_modules\@wdio\utils\build\index.js:1559:14)


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

### Is there an existing issue for this?

- [X] I have searched the existing issues
wdio-bot commented 1 day ago

Thanks for reporting!

We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers!