How to handle Frames/iFrames in Selenium with Python Last Updated : 08 Jul, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report Selenium is an effective device for controlling an internet browser through 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:- switch_to.frame(name) Process: 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 methodGo back to the default frame.Then go to the 2nd frameFind element using the link text methodGo back to the default frameThen switch to the 3rd frame.Then find element by x path. Implementation: Python3 # importing the modules from selenium import webdriver from selenium.webdriver.support.ui import Select import time # using chrome driver driver = webdriver.Chrome() # web page url driver.get("https://www.selenium.dev/selenium/docs/api/java/index.html") # switch to 1st frame driver.switch_to.frame("packageListFrame") # click on 1st frame driver.find_element_by_link_text("org.openqa.selenium.opera").click() # back to default web page frame driver.switch_to.default_content() # switch to 2nd frame driver.switch_to.frame("packageFrame") # click on 2nd frame driver.find_element_by_link_text("OperaOptions").click() # back to default web page frame driver.switch_to.default_content() # switch to 3rd frame driver.switch_to.frame("classFrame") # click on 2nd frame driver.find_element_by_xpath('/html/body/div[1]/ul/li[4]/a').click() time.sleep(4) Output:- Comment More infoAdvertise with us Next Article How to use close() and quit() method in Selenium Python ? P praveeny182 Follow Improve Article Tags : Python Python-selenium Practice Tags : python Similar Reads How to handle alert prompts in Selenium Python ? Seleniumâs Python Module is built to perform automated testing with Python. Alerts are a way to show popups in the browser for either accepting data or displaying data. Selenium provides methods to handle alerts of all kinds. Seleniumâs Python Module is built to perform automated testing with Python 2 min read How to make Firefox headless programmatically in Selenium with Python? Selenium is a powerful tool for web automation and testing. You can use Firefox in headless mode when you need to automate web interactions without a visible browser window. Running Firefox headless allows you to perform tasks like automated testing, web scraping, and server-side rendering more effi 6 min read How to check if an element exists with Python Selenium? Selenium is one of the most powerful and widely used tools for web automating web applications. Whether you're a software developer or a QA tester, Selenium is an important tool to have in your toolkit. Selenium is widely used for automating user interactions like clicking buttons, filling out the f 7 min read How to use close() and quit() method in Selenium Python ? While doing stuff with selenium multiple browsers with multiple tabs will normally opens in order to close these tabs close() and quit() methods are used. close() method is used to close the current browser window on which the focus is set, on the other hand quit() method essentially calls the drive 2 min read How to switch to new window in Selenium for Python? Selenium is the most used Python tool for testing and automation for the web. But the problem occurs when it comes to a scenario where users need to switch between windows in chrome. Hence, selenium got that cover as well. Selenium uses these methods for this task- window_handles is used for working 3 min read How to access popup login window in selenium using Python Many websites use sign-in using social media to make the login process easy for users. In most cases, if the button is clicked then a new popup window is opened where the user has to enter their user credentials. Manually one can switch windows in a browser and enter the required credentials to log 3 min read Like