【发布时间】:2016-10-07 08:54:49
【问题描述】:
我正在更新一个使用 Selenium webdriver 进行浏览器测试的 C# 测试框架。启动每个测试用例后,我需要绕过 Windows 安全弹出窗口(IE11:v11.187.14393.0)才能进入我正在测试的开发站点。我以前使用 AutoIt 和以下代码进行过这项工作。
AutoItX3 autoIt = new AutoItX3();
string windowTitle = "Windows Security";
// Wait 30 seconds max...
autoIt.WinWait(windowTitle, string.Empty, 30);
// Need to wait for input fields to load...
Thread.Sleep(2000);
autoIt.WinActivate(windowTitle);
autoIt.ControlSetText(windowTitle, string.Empty, "[CLASS:Edit; INSTANCE:1]", username);
autoIt.ControlSetText(windowTitle, string.Empty, "[CLASS:Edit; INSTANCE:2]", password);
autoIt.ControlClick(windowTitle, "OK", "[CLASS:Button; INSTANCE:2]");
autoIt.WinWaitClose(windowTitle, string.Empty, 10);
我已经将我的操作系统更新到 Windows 10,并且弹出框已经改变(见下文)
See new security popup example
See old secruity popup example
AutoIt 检查器不再为安全弹出窗口中的任何对象返回任何控制信息,因此我无法与它们交互。 (见下文他的检查员为用户名输入框返回的内容)
窗口
控制 实例:
类名NN:
名称:
高级(类):
ID: 正文:
当前位置:
尺寸:
ControlClick 坐标:
风格:
ExStyle:
句柄:鼠标
状态栏
工具栏
可见文本
隐藏文字
我尝试将 AutoIt 指向活动窗口并直接发送密钥,但这也不起作用。 (见下面的代码)。
string windowTitle = "Windows Security";
// Wait 30 seconds max...
autoIt.WinWait(windowTitle, string.Empty, 30);
// Need to wait for input fields to load...
Thread.Sleep(2000);
autoIt.WinActivate(windowTitle);
autoIt.Send(username);
autoIt.Send(Keys.Tab.ToString());
autoIt.Send(password);
autoIt.Send(Keys.Enter.ToString());
autoIt.WinWaitClose(windowTitle, string.Empty, 10);
有没有人知道我该如何克服这个问题?
谢谢
【问题讨论】:
标签: c# internet-explorer-11 ui-automation autoit-c#-wrapper