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

How does nodriver switch iframes? Does the “.switch_to.frame” function exist? #1856

Open
w956205480 opened this issue May 2, 2024 · 6 comments

Comments

@w956205480
Copy link

I want to click a button in an iframe, with selenium I use switch_to.frame for switching, but I don't find it in nodriver?

@flaming-chameleon
Copy link

Did you found solution?

@LinuxTux193
Copy link

same problem

@flaming-chameleon
Copy link

flaming-chameleon commented May 26, 2024

I made custom function for this component which work for me:

    async def switch_to_frame(self, frame):
        iframe_tab: uc.Tab = next(
                filter(
                    lambda x: str(x.target.target_id) == str(frame.frame_id), self.browser.targets
                )
            )
        return iframe_tab```

@LinuxTux193
Copy link

do you know why i can't find my iframe in the browser.targets? i'm already using --disable-web-security

@TempJannik
Copy link

do you know why i can't find my iframe in the browser.targets? i'm already using --disable-web-security

Same issue for me, have you found a solution?

@LinuxTux193
Copy link

LinuxTux193 commented May 30, 2024

do you know why i can't find my iframe in the browser.targets? i'm already using --disable-web-security

Same issue for me, have you found a solution?

Yeah, i just used tab.evaluate to run javascript and do it in javascript.
Here's an example

let iframe = document.querySelector("YOUR_IFRAME_SELECTOR")
let iframe_tab = iframe.contentWindow.document.body;
 //run your code using iframe_tab instead of document (ex. iframe_tab.querySelector("#payment"))

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

4 participants