Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to handle Frames/iFrames in Selenium with Python

  • Last Updated : 11 Oct, 2020

Selenium is an effective device for controlling an internet browser thru the program. It is purposeful for all browsers, works on all fundamental OS and its scripts are written in numerous languages i.e Python, Java, C#, etc, we can be running with Python.

HTML outlines are utilized to isolate your program window into numerous segments where each part can stack a different HTML report. An assortment of edges in the program window is known as a frame set. The window is partitioned into outlines likewise the tables are composed: into lines and segments.

Requirement: You need to install chromedriver and set path. Click here to download.for more information follows this link.

 Handle Frames/iFrames:-



This web page is divided into three frames, left top (1st frame) and left bottom(2nd frame) and the third frame. All the frames interconnected. Then we perform these actions by selenium:

  • First of all, switch to the default frame to the first frame.
  • Then find the element using link text method
  • Go back to the default frame.
  • Then go to the 2nd frame
  • Find element using the link text method
  • Go back to the default frame
  • Then switch to the 3rd frame.
  • Then find element by x path.



# importing the modules
from selenium import webdriver
from import Select
import time
# using chrome driver
driver = webdriver.Chrome()
# web page url
# switch to 1st frame
# click on 1st frame
# back to default web page frame
# switch to 2nd frame
# click on  2nd frame 
# back to default web page frame
# switch to 3rd frame
# click on  2nd frame


 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!