我的selenium脚本适用于驱动程序Chromedriver,IEDriver 当我没有连接到VPN时。
但是当我尝试在连接到VPN 时运行相同的脚本时 仅适用于Chromedriver , 对于 IEDriver ,只需浏览器打开,最大化,获取网址以及之后 以下错误会跳过所有场景。
org.openqa.selenium.NoSuchWindowException:无法获取浏览器(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:17毫秒
注意:调试时我注意到了,
在浏览器窗口打开后,在getUrl()之后 我试着getCurrenturl()并获得了以下结果。 对于 IE,它给出了实际Url的initialBrowserUrl instad 。
IEDriver记录:
[testng]Started InternetExplorerDriver server (32-bit)
[testng] 2.53.1.0
[testng] Listening on port 28196
[testng] Only local connections are allowed
[testng] Actual URL url : mydomain.com/XYZApplication/
[testng] getCurrenturl (driver.getCurrenturl): localhost:28196/
Chromedriver日志:
[testng] Starting ChromeDriver 2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129) on port 8160
[testng] Only local connections are allowed.
[testng] test url : mydomain.com/XYZApplication/
[testng] getCurrenturl (driver.getCurrenturl) : mydomain.com/XYZApplication/
答案 0 :(得分:1)
您可能需要使用浏览器传递IE首选项。堆栈跟踪是非常开放的,所以我不确定问题是什么。由于我遇到的IE问题,我在过去一年中设置了一些偏好。如果没有VPN,您可能不需要这些
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
caps.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, " mydomain.com/XYZApplication/");
caps.setCapability(InternetExplorerDriver.ENABLE_ELEMENT_CACHE_CLEANUP, true);
caps.setCapability("ignoreProtectedModeSettings", true);
caps.setCapability("ignoreZoomSetting", true);
caps.setCapability("nativeEvents", false);
caps.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
caps.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
caps.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
driver = new InternetExplorerDriver(caps);
driver.manage().window().maximize();