import java.util.concurrent.TimeUnit;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class FrameExample
{
public static void main(String[] args)
{
System.setProperty("webdriver.chrome.driver", "D:/PROGRAMMING SOFTWARES/Selenium/chromedriver_win32/chromedriver.exe");
WebDriver driver=new ChromeDriver();
// WebDriver driver=new FirefoxDriver();
WebDriverWait wait=new WebDriverWait(driver, 5, 2000);
wait.ignoring(NoSuchElementException.class,TimeoutException.class);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("menu"));
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//*[text()='Example 1']"))).click();
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("menu"));
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//*[text()='Example 2']"))).click();
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("menu"));
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//*[text()='Example 3']"))).click();
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("menu"));
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//*[text()='Example 4']"))).click();
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("menu"));
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//*[text()='Example 5']"))).click();
driver.close();
}
}