尽管有两个打开的窗口,但Driver.getWindowHandles()在Windows 10的IE11中始终返回1 [英] Driver.getWindowHandles() is always returning 1 in IE11 on Windows 10, although there are two windows open

查看:58
本文介绍了尽管有两个打开的窗口,但Driver.getWindowHandles()在Windows 10的IE11中始终返回1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文中的代码:

    Set<String> handles = driver.getWindowHandles();

        String firstWinHandle = driver.getWindowHandle(); 
        handles.remove(firstWinHandle);

        String winHandle=handles.iterator().next();

        if (winHandle!=firstWinHandle){

            //To retrieve the handle of second window, extracting the handle which does not match to first window handle

            String secondWinHandle=winHandle; //Storing handle of second window handle

            //Switch control to new window

            driver.switchTo().window(secondWinHandle);
        }

此代码在Windows 7和Windows 8.1上的IE11上可以完美切换到第二个窗口,但在Windows 10上不起作用.

This code works perfectly on IE11 on Windows 7 and Windows 8.1 to switch to the second window, but doesn't work on Windows 10.

对于Windows 10,行的 Java.util.NoSuchElement异常出现

In case of Windows 10, Java.util.NoSuchElement Exception appears for line

字符串winHandle = handles.iterator().next();

使用的硒和IE版本为2.53.1.

推荐答案

我遇到了同样的问题.在所有区域的IE设置中禁用保护模式很有帮助.

I had the same problem. Disabling the protected mode in the IE settings for all zones helped.

这篇关于尽管有两个打开的窗口,但Driver.getWindowHandles()在Windows 10的IE11中始终返回1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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