Monday 11 May 2015

Truely amazing!! "How to hadle multiple frames in webDriver"

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;


public class FrameExampleDemo {

public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://seleniumhq.github.io/selenium/docs/api/java/index.html");

//pass the driver control to frame-1
driver.switchTo().frame("classFrame");

//perform operation on frame-1
driver.findElement(By.linkText("com.thoughtworks.selenium")).click();

//pass the driver control to top-window(Parent)
driver.switchTo().defaultContent();

//pass the driver control to frame-2
driver.switchTo().frame("packageFrame");

//perform the operation on frame-2
driver.findElement(By.linkText("AddWebStorage")).click();



}

}

No comments:

Post a Comment