Selenium与IE11无法识别使用python中的windows_handles打开的​​其他窗口 [英] Selenium with IE11 does not identify the other window opens using windows_handles in python

查看:341
本文介绍了Selenium与IE11无法识别使用python中的windows_handles打开的​​其他窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在使用硒3.6,IE Web驱动程序版本为3.4.

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

我的应用程序中有一个区域需要单击下载excel的按钮.当我使用硒在IE中执行此操作时,它会打开IE的新窗口(手动操作时不会发生)以及正常下载弹出.

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.

当我尝试识别另一个打开的窗口时,在python中使用window_handles方法无法识别另一个窗口,因为window_handles仅识别主窗口.

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.

配置详细信息: IE版本11.17 Windows 10 语言:python 3.4

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

推荐答案

我在IE8上也遇到了类似的问题.在使用window_handles之前,我应该切换到默认内容.这样可以识别更多窗口.

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.

我知道您正在使用Python,但这的Java代码是:

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);

我认为在Python上的步骤是相同的​​.

I think the steps are the same on Python.

这篇关于Selenium与IE11无法识别使用python中的windows_handles打开的​​其他窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆