In a page we will be handling the windows to achieve this the small piece of code is required.
package TestNG;
import java.util.Iterator;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Demo7 {
public static void main(String[] args) {
WebDriver driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.get("http://www.naukri.com");
Iterator<String> Wh = driver.getWindowHandles().iterator();
String Parent = Wh.next();
String Child1 = Wh.next();
String Child2 = Wh.next();
driver.switchTo().window(Child2);
driver.get("www.google.com/");
driver.close();
driver.switchTo().window(Child1);
driver.get("https://www.facebook.com/");
driver.close();
driver.switchTo().window(Parent);
driver.get("https://demo.vtiger.com/index.php#");
driver.close();
}
}
To know FAQ's on Selenium Please ClickHere
To know SQL's Queries Required For Testers Please ClickHere
No comments:
Post a Comment