-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
WebdriverIO Version
9.5.7
Node.js Version
20.15.1
Mode
WDIO Testrunner
Which capabilities are you using?
capabilities: [{
browserName: 'chrome'
}, {
browserName: 'firefox'
}],What happened?
I have an Iframe that is inserted to the dom at some point.
I use browser.switchFrame to switch to that iframe.
I found out, that switchFrame seems to wait for the iframe to appear, but then it fails anyway.
I can see that, because switchFrame takes longer, the longer it takes to load the iframe.
In the same moment the iframe appears, switchFrame fails.
it(`(almost) waits automatically for delayedIframe`, async () => {
await expect( () => browser.switchFrame(delayedIframe())).rejects.toThrow();
// this means, that switchFrame waited, but failed anyway.
await expect(delayedIframe()).toExist({wait:0});
await expect(h1()).toHaveText("Delayed Iframe"); // still in parent frame
});I tried to create a helper function, that wraps browser.switchFrame and additionally waits using .waitForExist.
But this fails with different errors in chrome and firefox:
- firefox:
WebDriver Bidi command "script.callFunction" failed with error: invalid argument - Expected "type" to be a string, got [object Undefined] undefined - chrome:
WebDriver Bidi command "script.callFunction" failed with error: invalid argument - Invalid input in "arguments"/0.
it(`should let us use our custom switchFrame to wait for delayedIframe`, async () => {
await switchFrame(delayedIframe());
await expect(h1()).toHaveText("Delayed Inner Iframe");
});
async function switchFrame(sel: ChainablePromiseElement) {
await sel.waitForExist();
await browser.switchFrame(sel);
}What is your expected behavior?
Since we are almost there, I think browser.switchFrame should not fail, but properly switch the frame, after it waited.
Well, and I think it should be possible to pass a selector to another function and use it there.
How to reproduce the bug.
I created a repository that I can reuse to report bugs: https://github.com/htho/wdio-repro-collection
git clone https://github.com/htho/wdio-repro-collection.gitcd wdio-repro-collectionnpm cinpm run test:delayedIframe
Relevant log output
I included error messages above, the other messages can be reproduced in the repository.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