Switch to iframe by using switch_to.frame() method and iframe id.
Example:
IFrames_by_WebElement.py
from selenium.webdriver.common.by import By from selenium import webdriver import time driver = webdriver.Chrome("/Users/admin/Documents/Others/Drivers/chromedriver.exe") # Using Chrome Driver driver.get("http://www.dummypoint.com/Frame.html") assert "Selenium Template" in driver.title ele = driver.find_elements(By.TAG_NAME, "iframe") # To display number of Iframes in web page print("List of iframe : ", len(ele)) # Switch to iframe by locator(ID) value time.sleep(2) ele = driver.find_element(By.ID,"f2") driver.switch_to.frame(ele) # After switching getting the text from iframe using ID locator data = driver.find_element(By.ID,"framename") print("Frame Name is : ",data.text) time.sleep(2) driver.quit()