How to deal with ModalDialog using selenium webdriver?

后端 未结 8 1754
天命终不由人
天命终不由人 2020-12-01 14:33

I am unable to switch to Modal Dialog of given example

http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModalDialog2.htm

I don\'t kno

8条回答
  •  情歌与酒
    2020-12-01 15:31

    Try this code, include your object names & variable to work.

    Set windowids = driver.getWindowHandles();
    Iterator iter= windowids.iterator();
    for (int i = 1; i < sh.getRows(); i++)
    {   
    while(iter.hasNext())
    {
    System.out.println("Main Window ID :"+iter.next());
    }
    driver.findElement(By.id("lgnLogin_UserName")).clear();
    driver.findElement(By.id("lgnLogin_UserName")).sendKeys(sh.getCell(0, 
    i).getContents());
    driver.findElement(By.id("lgnLogin_Password")).clear();
    driver.findElement(By.id("lgnLogin_Password")).sendKeys(sh.getCell(1, 
    i).getContents());
    driver.findElement(By.id("lgnLogin_LoginButton")).click();
    Thread.sleep(5000L);
                windowids = driver.getWindowHandles();
        iter= windowids.iterator();
        String main_windowID=iter.next();
        String tabbed_windowID=iter.next();
        System.out.println("Main Window ID :"+main_windowID);
        //switch over to pop-up window
        Thread.sleep(1000);
        driver.switchTo().window(tabbed_windowID);
        System.out.println("Pop-up window Title : "+driver.getTitle());
    

提交回复
热议问题