Sunday 5 June 2022

How To Count Number of Frames in Selenium WebDriver Java

                 In this post, we will see How To Count Number of Frames in Selenium WebDriver Java 


Program Code:

import java.util.List;


import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.chrome.ChromeDriver;


public class CountFrames {


public static void main(String[] args) {

System.setProperty("webdriver.chrome.driver", "C:\\selenium\\chromedriver_win32\\chromedriver.exe");

WebDriver driver=new ChromeDriver();

driver.get("https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_confirm");

driver.manage().window().maximize();

List<WebElement> l=driver.findElements(By.tagName("iframe"));

System.out.println("No. of frames in webpage="+l.size());

}



Watch following video:


Watch on YouTube: https://www.youtube.com/watch?v=WMRp-rlY5yg

No comments:

Post a Comment