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

Add a Context Manager method for switching into iframes using a "with" statement #1408

Closed
mdmintz opened this issue Jul 13, 2022 · 0 comments · Fixed by #1409
Closed

Add a Context Manager method for switching into iframes using a "with" statement #1408

mdmintz opened this issue Jul 13, 2022 · 0 comments · Fixed by #1409
Assignees
Labels
enhancement Making things better

Comments

@mdmintz
Copy link
Member

mdmintz commented Jul 13, 2022

Add a Context Manager method for switching into iframes using a with statement.

While inside the with block, the browser should be within the iframe control.

Here's an example test that should demonstrate this feature:

from seleniumbase import BaseCase

class FrameTests(BaseCase):
    def test_iframes_with_context_manager(self):
        self.open("https://seleniumbase.io/w3schools/iframes.html")
        with self.frame_switch("iframeResult"):
            self.assert_text("HTML Iframes", "h2")
            with self.frame_switch('[title*="Iframe"]'):
                self.assert_text("This page is displayed in an iframe", "h1")
            self.assert_text("Use CSS width & height to specify", "p")
            with self.frame_switch('[title*="Iframe"]'):
                self.assert_text("seleniumbase.io/w3schools/iframes", "a")
        self.click("button#runbtn")
        with self.frame_switch("iframeResult"):
            self.highlight('iframe[title="Iframe Example"]')

(Based on #1407)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Making things better
Projects
None yet
1 participant