Webpage >> Frame >> popup window handling

后端 未结 1 1177
迷失自我
迷失自我 2021-01-26 12:09

I have this webpage which I am trying to automate. here are the steps and functioning of application.

  1. Launch Application using Selenium
  2. On clicking certai
1条回答
  •  别那么骄傲
    2021-01-26 12:17

    Try like this:

            String mainWindow = driver.getWindowHandle();
            Set windows= driver.getWindowHandles();
            if (windows.size() > 1) {
                //first remove main window
                windows.remove(mainWindow);
                //switching to new/child window and perform some action on new window if required. Then close it.
                driver.switchTo().window(windows.iterator().next());
                driver.close();
                //switching back to mainWindow, Then continue with your actions.
                driver.switchTo().window(mainWindow);
                windows.clear();
            }
    

    0 讨论(0)
提交回复
热议问题