gpt4 book ai didi

java - Selenium webDriver 2.46 卡在使用 switchto.window 切换窗口上

转载 作者:行者123 更新时间:2023-12-01 11:17:42 28 4
gpt4 key购买 nike

我们的测试用例中有一个场景,我们必须将控制从父窗口切换到子窗口(单独)。

我们可以使用以下代码在 Chrome 和 FF 上完成此操作:

Set<String> winHandles = gblConstants.objdriver.getWindowHandles();

System.out.println(gblConstants.objdriver.getWindowHandles().size());

for (String winHandle : winHandles )
{

if(!(winHandle.equals(Keywords.parentWindowHandle)))
{

WebDriver driver = gblConstants.objdriver.switchTo().window(winHandle);

blnRes = true;

driver.window().maximize();

break;

}
}

但是当我们尝试在IE11上执行上述代码时,执行卡住在:

 WebDriver driver = gblConstants.objdriver.switchTo().window(winHandle);

客户端:Java,

Selenium WebDriver - 2.46

操作系统:Windows 7

请帮助完成这项工作。提前致谢。

最佳答案

我遇到了类似的问题,直到有人提醒我运行我们用来设置 IE 进行 webdriver 测试的配置脚本。这些人中的一个(或多个)可能会为您解决问题。至少我的测试不再挂起。

@ECHO OFF
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom" /v "ZoomFactor" /t REG_DWORD /d 0x000186a0 /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1" /v "2500" /t REG_DWORD /d 0x00000000 /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "2500" /t REG_DWORD /d 0x00000000 /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "2500" /t REG_DWORD /d 0x00000000 /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\4" /v "2500" /t REG_DWORD /d 0x00000000 /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main" /v "Check_Associations" /t REG_SZ /d "no" /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation" /v "IntranetCompatibilityMode" /t REG_DWORD /d 0x00000000 /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Recovery" /v "AutoRecover" /t REG_DWORD /d 0x00000002 /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "Flags" /t REG_DWORD /d 0x00000043 /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\global.pvt\*.pbi" /v "*" /t REG_DWORD /d 0x00000002 /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "2101" /t REG_DWORD /d 0x00000000 /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client" /v "RemoteDesktop_SuppressWhenMinimized" /t REG_DWORD /d 0x00000002 /f

关于java - Selenium webDriver 2.46 卡在使用 switchto.window 切换窗口上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31608271/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com