Check Number of IFrames

len() method

This method is used to count the number of iframes on the webpage.It takes webelement as an argument.


Example:

 

Count_IFrames_On_WebPage.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

iframe_data = driver.find_elements(By.TAG_NAME, "iframe")

# To display number of Iframes in web page
print("List of iframes : ", len(iframe_data))

time.sleep(5)
driver.quit()