python selenium下载窗口 ie_Selenium与IE11无法识别使用python中的windows_handles打开的​​其他窗口...

在使用Selenium 3.6与IE浏览器3.4版本时,遇到点击下载按钮会打开新窗口的问题,这在手动操作时并不会发生。下载弹窗出现的同时,还会打开一个额外的IE窗口,通过Python的window_handles方法无法识别这个新窗口。解决方案是切换到默认内容后再处理窗口。Java代码示例给出了解决方法,虽然问题是在Python环境下,但步骤应该类似。
摘要由CSDN通过智能技术生成

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

解决方案

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值