selenium switch to iframe code example
Example 1: selenium python switch to iframe
# go to iframe
driver.switch_to.frame(iframe)
# back to previous frame
driver.switch_to.parent_frame()
Example 2: how to handle iframes
- Iframe is html inside another html
- We need to switch selenium focus to iframe
either by using INDEX, NAME-ID, or
as a webelement same way as other webelements.
After switching to Iframe we need to switch back to
the main frame to able to continue in the main frame.
Syntax=
-driver.switchTo().defaultContent();
-driver.switchTo().parentFrame();