4.6 Handling frames
@Test
public void testMethod() {
WebDriver driver = new FirefoxDriver();
// URLs to be verified..
String expectedresult[] = { "Google","W3Schools Online Web Tutorials","Sparsh", "Delicious" };
int count = 0;
// We are fetching all the values in dropdown below and clicking one by one
driver.findElement(By.xpath("/someXpath/to/dropdownLinks")).click();
// Here we switch to newly opened frame
driver.switchTo().frame("frameName");
//Perform actions in this frame
System.out.println(driver.getTitle());
// Switch back to the window
driver.switchTo().defaultContent();
}Last updated