I FRAMES

  

package mypackage;

 

import java.util.concurrent.TimeUnit;

 

import  org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.support.ui.Select;

 

public class IFrames {

 

public static void main(String[] args)  {

System.setProperty("webdriver.gecko.driver","C:\\Browser\\geckodriver.exe");

WebDriver driver=new FirefoxDriver();

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

driver.get("http://www.google.com");

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

                   

driver.navigate().to("https://chercher.tech/practice/frames-example-selenium-webdriver");

                   

int framecount=driver.findElements(By.tagName("iframe")).size();

System.out.println(framecount);

                   

driver.switchTo().frame("frame2");

WebElement option=driver.findElement(By.id("animals"));

Select so=new Select(option);

so.selectByIndex(2);

                   

driver.switchTo().defaultContent();


driver.switchTo().frame("frame1");

driver.findElement(By.xpath("//input[@type='text']")).sendKeys("selenium");

                   

Thread.sleep(5000);

driver.quit();

}