Showing posts with label How to run selenium scripts in different browsers?. Show all posts
Showing posts with label How to run selenium scripts in different browsers?. Show all posts

How to handle multiple windows in Selenium?


Example of handling Multiple Windows in Selenium:

public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
WebDriver driver = new FirefoxDriver();
driver.get("https://www.abc.com/");
driver.manage().window().maximize();
String Window1 = driver.getWindowHandle();
driver.findElement(By.linkText("Contact us Now")).click();
for (String Window2 : driver.getWindowHandles())
{
driver.switchTo().window(Window2);
}
driver.findElement(By.xpath("//*[@id='bigin']")).sendKeys("abcde");
Thread.sleep(5000);
driver.close();
driver.switchTo().window(Window1);
driver.getTitle();
Thread.sleep(3000);
driver.close();
}

For more info, Contact Us

How to Set up a Project in Eclipse?




¨> Open eclipse (To download eclipse 64 bit or 32 bit, click here)
¨> Right click on Package Explorer > New > Java Project
¨> Give a Project name and click Next
¨> Go to Selenium downloads page and download Java Language bindings (Or Click Here to download Selenium latest jars)