Recall & Review
beginner
What is an iFrame in web testing?
An iFrame is a webpage embedded inside another webpage. It allows loading a separate HTML document within the main page.
Click to reveal answer
beginner
Why do we need to switch to an iFrame in Selenium?
Because elements inside an iFrame are in a different document, Selenium must switch its focus to that iFrame to interact with those elements.
Click to reveal answer
beginner
How do you switch to an iFrame by its name or ID in Selenium Python?
Use driver.switch_to.frame('frame_name_or_id') to switch focus to the iFrame with that name or ID.
Click to reveal answer
intermediate
How can you switch to an iFrame using a WebElement in Selenium Python?
First find the iFrame element with driver.find_element, then switch using driver.switch_to.frame(iframe_element).
Click to reveal answer
beginner
How do you switch back to the main page from an iFrame in Selenium?
Use driver.switch_to.default_content() to return focus to the main page from any iFrame.
Click to reveal answer
What happens if you try to locate an element inside an iFrame without switching to it first?
✗ Incorrect
Selenium cannot see elements inside an iFrame unless you switch to it first, so it throws NoSuchElementException.
Which Selenium command switches focus back to the main page from an iFrame?
✗ Incorrect
driver.switch_to.default_content() returns focus to the main page from any iFrame.
How can you switch to an iFrame using a WebElement in Selenium Python?
✗ Incorrect
You can pass the WebElement representing the iFrame to driver.switch_to.frame() to switch focus.
If an iFrame has no name or ID, how can you switch to it?
✗ Incorrect
You can switch to an iFrame by its index position on the page if it has no name or ID.
What is the correct way to switch to the parent frame from a nested iFrame?
✗ Incorrect
driver.switch_to.parent_frame() switches focus to the immediate parent frame of the current iFrame.
Explain why switching to an iFrame is necessary before interacting with its elements in Selenium.
Think about how a webpage can have a mini webpage inside it.
You got /3 concepts.
Describe the different ways to switch to an iFrame using Selenium Python.
Consider what identifiers an iFrame can have.
You got /3 concepts.