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
[🐛 Bug]: window.frameElement
always evaluating to null
#12844
Comments
@KuznetsovRoman is it only for |
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! |
No, when i change it to "webdriver", nothing changes |
@KuznetsovRoman can you share WebdriverIO logs when running with WebDriver? |
And looks like with webdriver protocol i can't get |
UPD: INVALID. Don't need to be looked at.Also with "webdriver" protocol i can't get "documentElement" or any other element with "browser.execute":Having the script: await session.url("https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe");
const divElement1 = await session.findElement('css selector', 'div') // getting div with findElement
const divElement2 = await session.execute('document.querySelector("div")') // getting div with execute
console.log({ divElement1, divElement2 }); I get this output with devtools protocol: devtools logs
So And here is the output with webdriver protocol: webdriver logs
|
@KuznetsovRoman missing |
Oh. It is not needed in devtools, but IS needed in webdriver. That works, thanks. Not with |
This is because this object can't be serialized. Note the in WebDriver all objects you return need to be serializeable. Mind trying to return a specific string or boolean property? |
But i can use { "element-6066-11e4-a52e-4f735466cecf": "f.B8857766B2104CC0DBB1D43DEB0F3C3A.d.F61D61186B7F43EDA24E8DEAE54EA227.e.8" } And it is a valid webdriver element. So why can't i get similar result with |
Yeah, looks like Actually, i don't need exactly
|
I was not using WebdriverIO for this screenshot, this is just my default browser console. Can you verify you can actually access this property, since it can be |
I can't access the property. I found an iframe example where
That is webdriver protocol. With What is the intended way to get currentFrame with webdriver then? How to check if i am inside of some frame? |
Can you provide a reproducible example? |
This one should work: import { remote as wdioRemote } from "webdriverio";
const session = await wdioRemote({
automationProtocol: "webdriver",
port: 9515,
hostname: "localhost",
capabilities: {
browserName: 'chrome',
},
})
await session.url("https://www.youtube.com/");
const myIframe = await session.findElement('css selector', 'iframe') // getting iframe
await session.switchToFrame(myIframe) // switching frame
const childFrameElement = await session.execute('return globalThis.frameElement') // should not be null
console.log({childFrameElement}) It throws "stale element not found in the current frame" at "session.execute" |
Thank you. I can confirm that it would expect that returning the I possible workaround would be something like this: import { remote as wdioRemote } from './packages/webdriverio/build/index.js'
const session = await wdioRemote({
capabilities: {
browserName: 'chrome',
},
})
await session.url('https://www.youtube.com/')
const myIframe = await session.findElement('css selector', 'iframe') // getting iframe
await session.switchToFrame(myIframe) // switching frame
const frameId = Date.now().toString()
await session.execute((frameId) => {
globalThis.frameElement?.setAttribute('data-frame-id', frameId)
}, frameId)
await session.switchToParentFrame()
console.log(await session.$(`iframe[data-frame-id="${frameId}"]`)) I will go ahead and close this as I don't see how WebdriverIO can help mitigate this issue since it is rather a protocol issue. Let me know if you have further problems. |
Have you read the Contributing Guidelines on issues?
WebdriverIO Version
8.20.0
Node.js Version
18.12.1
Mode
Standalone Mode
Which capabilities are you using?
What happened?
I haven't found any way to get current frame with webdriverio methods, so iam trying to use
browser.execute(globalThis.frameElement)
to get currentFrame (to switch back afterswitchToFrame
), but it always resolvesnull
, though it works in browser console.What is your expected behavior?
I expect to get an element reference, just like with
findElement
or when i executedocument.documentElement
.How to reproduce the bug.
Relevant log output
Code of Conduct
Is there an existing issue for this?
The text was updated successfully, but these errors were encountered: