unpredictable popup excercise code
ignore previous code.. import java.util.Iterator; import java.util.Set; import java.util.concurrent.TimeUnit; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class Popup_Excer { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get("http://www.qtpselenium.com/test/unpredictable.php"); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS); Set<String> str = driver.getWindowHandles(); Iterator<String> itr = str.iterator(); String mainwindow= itr.next(); System.out.println(mainwindow); while(itr.hasNext()){ String popupwindow =itr.next().toString(); driver.switchTo().window(popupwindow); driver.close(); driver.switchTo().window(mainwindow); System.out.println(mainwindow); } } }
The window handler concept is not working for me. I guess its not working since this is a hidden div popup. Thanks for trying and sorry for late reply.
[quote="[email protected]":2rccxxx8]ignore previous code.. [code:2rccxxx8] import java.util.Iterator; import java.util.Set; import java.util.concurrent.TimeUnit; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class Popup_Excer { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get("http://www.qtpselenium.com/test/unpredictable.php"); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS); Set<String> str = driver.getWindowHandles(); Iterator<String> itr = str.iterator(); String mainwindow= itr.next(); System.out.println(mainwindow); while(itr.hasNext()){ String popupwindow =itr.next().toString(); driver.switchTo().window(popupwindow); driver.close(); driver.switchTo().window(mainwindow); System.out.println(mainwindow); } } }[/code:2rccxxx8][/quote:2rccxxx8] seems to be okay. have you tried running it? it is the only way to know for sure.
We offer online selenium and UFT/QTP training. The course is very comprehensive and covers every aspect of automation testing with UFT/QTP and selenium. All types of frameworks are covered in depth - data driven framework, hybrid framework, page object model with a live project
© 2020 Whizdom Trainings. All rights Reserved - Powered by Whizdom Trainings