Selenium with IE11 does not identify the other window opens using windows_handles in python

早过忘川 提交于 2020-01-06 07:19:13

问题


Currently i'm using selenium 3.6 with IE web driver version as 3.4.

There is an area in my application where i have to click on a button which downloads an excel.When i do this in IE using selenium it opens a new window of IE (not happening when you do manually) along with normal download pop up.

When i tried to identify the other window which was opened, using window_handles method in python i'm not able to identify the other window as the window_handles is only identifying the main window.

Config details: IE version 11.17 Windows 10 language :python 3.4


回答1:


I had a similar problem with IE8. I had should do a switch to default content, before use the window_handles. That way identify more windows.

I know you are using Python, but the Java code for this is:

    // Take the parent id before change
    String parent = driver.getWindowHandle();
    for (String winHandle : driver.getWindowHandles()) {
        driver.switchTo().window(winHandle);
        if (!winHandle.equals(parent)) {
            driver.close();
        }
    }
    driver.switchTo().window(parent);

I think the steps are the same on Python.



来源:https://stackoverflow.com/questions/46966305/selenium-with-ie11-does-not-identify-the-other-window-opens-using-windows-handle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!