URGENT-- Badly stuck to find the Unique WIndow Id of a PopUp
URGENT-- Badly stuck to find the Unique WIndow Id of a PopUp
M
Posted on 30/05/2016
Hi, Please help me, I am badly stuck to found the Unique Window id of a Pop Up under a POP up :-
[b:1de1zlvw]NOTE :- Please refer the attached sheet in which i describe step by step and look into below complete code :-[/b:1de1zlvw] [b:1de1zlvw] COMPLETE CODE :-[/b:1de1zlvw]
public class MMs_test { static WebDriver driver; public static void main(String[] args) throws InterruptedException { System.setProperty("webdriver.chrome.driver","D:\\chromedriver.exe"); driver = new ChromeDriver(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get("http://172.19.4.64/MR29/MMS/index.aspx"); Set<String> mainwindow = driver.getWindowHandles(); System.out.println("Total Numbers of the page --- > " +mainwindow.size()); Iterator<String> itr = mainwindow.iterator(); String FirstWindow = itr.next(); String SecondWindow = itr.next(); System.out.println("Parent Window id is --- >" +FirstWindow); System.out.println("Child Window id is --- >" +SecondWindow); driver.switchTo().window(SecondWindow); driver.findElement(By.xpath("//*[@id='txtUserName']")).sendKeys("careteststh"); driver.findElement(By.xpath("//*[@id='txtPassword']")).sendKeys("irctc@116"); driver.findElement(By.xpath("//*[@id='btnLogin']")).click(); //Thread.sleep(1000); driver.findElement(By.xpath("//*[@id='5001']/div/span")).click(); driver.findElement(By.xpath("//*[@id='5002']/div/span")).click(); driver.findElement(By.xpath("//*[@id='5003']/div/span")).click(); -----> [b:1de1zlvw]Code is working fine till that line but on next line i am not able to find out the unique window id of a pop up[/b:1de1zlvw] mainwindow = driver.getWindowHandles(); itr = mainwindow.iterator(); itr = mainwindow.iterator(); String FirstWindow1 = itr.next(); String SecondWindow1 = itr.next(); System.out.println("Parent Window id is --- >" +FirstWindow1); System.out.println("Child Window id is --- >" +SecondWindow1); driver.switchTo().window(SecondWindow1); System.out.println(driver.getTitle()); }
}
M
Replied on 31/05/2016
the images you send me seems to me like alert not a pop up.