- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我最近更新到了 Windows 7、VS2010 和 IE8。我们有一个自动化套件,使用 WatiN 对 IE 运行测试。这些测试需要使用登录对话框处理程序,以便将不同的 AD 用户登录到 IE 浏览器中。
这在使用 Windows XP 和 IE8 时效果很好,但现在使用 Windows 7 导致 Windows 安全对话框不再被识别,该对话框只是被忽略。这是用于启动浏览器的方法:
public static Browser StartBrowser(string url, string username, string password)
{
Browser browser = new IE();
WatiN.Core.DialogHandlers.LogonDialogHandler ldh = new WatiN.Core.DialogHandlers.LogonDialogHandler(username, password);
browser.DialogWatcher.Add(ldh);
browser.GoTo(url);
return browser;
}
任何建议或帮助将不胜感激......
最佳答案
无论出于何种原因,Clint 发布的代码都有注释,而不是输入用户名、密码并提交,并引用了未定义的方法,但其他方面都正常。这是一些已完成(且有效)的代码:
public static Browser Win7Login(string username, string password, string URL) {
Process ieProcess = Process.Start("iexplore.exe", URL);
ieProcess.WaitForInputIdle();
Thread.Sleep(2000);
AutomationElement ieWindow = AutomationElement.FromHandle(ieProcess.MainWindowHandle);
string t = ieWindow.Current.ClassName.ToString();
Condition conditions = new AndCondition(new PropertyCondition(AutomationElement.IsEnabledProperty, true),
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window));
Condition List_condition = new AndCondition(new PropertyCondition(AutomationElement.IsEnabledProperty, true),
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ListItem));
Condition Edit_condition = new AndCondition(new PropertyCondition(AutomationElement.IsEnabledProperty, true),
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit));
Condition button_conditions = new AndCondition(new PropertyCondition(AutomationElement.IsEnabledProperty, true),
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button));
AutomationElementCollection c = ieWindow.FindAll(TreeScope.Children, conditions);
foreach (AutomationElement child in c) {
if (child.Current.ClassName.ToString() == "#32770") {
// find the list
AutomationElementCollection lists = child.FindAll(TreeScope.Children, List_condition);
// find the buttons
AutomationElementCollection buttons = child.FindAll(TreeScope.Children, button_conditions);
foreach (AutomationElement list in lists) {
if (list.Current.ClassName.ToString() == "UserTile") {
AutomationElementCollection edits = list.FindAll(TreeScope.Children, Edit_condition);
foreach (AutomationElement edit in edits) {
if (edit.Current.Name.Contains("User name")) {
edit.SetFocus();
ValuePattern usernamePattern = edit.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
usernamePattern.SetValue(username);
}
if (edit.Current.Name.Contains("Password")) {
edit.SetFocus();
ValuePattern passwordPattern = edit.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
passwordPattern.SetValue(password);
}
}
}
}
foreach (AutomationElement button in buttons) {
if (button.Current.AutomationId == "SubmitButton") {
InvokePattern submitPattern = button.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
submitPattern.Invoke();
break;
}
}
}
}
return IE.AttachTo<IE>(Find.By("hwnd", ieWindow.Current.NativeWindowHandle.ToString()), 30);
}
关于windows-7 - WatiN LogonDialogHandlers 在 Windows 7 中无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2841120/
我正在尝试做快速入门示例,我在 VS2010 中使用 NuGet 引入了引用,我在网页上抓取了示例代码,我看到了我的 NUnit session 窗口,我单击了绿色箭头,但浏览器没有被调用(不启动)。
我正在使用 WATIR 和 WATIN 编写自动化脚本。 Watir 有一个叫做页面检查器的东西,它是在每次页面加载时运行的代码片段。 WATIN 中有类似的东西吗?我想要一段代码在每次页面加载时运行
只是想看看我是否可以阻止 Watin/IE 加载图像,从而使整个过程变得更快? 最佳答案 您可以通过 Internet Explorer 选项停止加载图像。 在 IE 中禁用图像: 选择工具 -> I
作为我的 WatiN 测试的一部分,我正在寻找一种通过 DTD 验证器传递我的网页的方法,但我还没有找到一种干净的方法来访问原始 HTML。有内置的方法吗? 我想我可以访问 IPersistStrea
我正在使用 WatiN 来测试自动完成下拉菜单。 当用户输入 3 个字符后在字段中键入时,将触发 jquery 自动完成并显示无序列表。用户必须从列表中进行选择。 我无法使用 WatiN 从列表中进行
我在尝试查找表中的项目时遇到一些问题 - 它要么为 null,要么我得到一个数组越界异常。这就是我想要做的。 这是我从页面解析的示例 html....
如何使用 WatiN 上传文件? 这个文件是否可以驻留在网络服务器上(与它在用户机器上相反)? 高度赞赏代码片段。谢谢。 最佳答案 该文件需要可供客户端浏览器访问。这意味着它要么需要在客户端机器上,要
由于未知原因,登录应用程序所需的时间显着增加。这通常不是问题;然而,我所做的一切似乎都无法阻止 Watin 超时。 单击“登录”按钮后,最多可能需要 1 分钟才能显示主页。我试过一些东西,比如: ie
我想使用 WatiN 来验证 JavaScript 警报框中的错误消息。这可能吗?谢谢。 最佳答案 见 Trev's Blog和 here以及。 using(IE ie = new IE("http:
我只是在试验用于 ASP.NET 应用程序的 WatiN 单元测试工具。我的页面设计有庞大而复杂的自定义控件列表。我们很难识别这些控件中的元素(例如:根据一些业务规则在我们的自定义网格中选择行是非常困
看起来 jssh 插件(运行 WatiN 需要)仍然需要 FireFox 处理 Bug 586869 , 报价: Probably obvious to anyone who ought to be
我最近才开始研究 WatiN,并遵循 http://www.codeproject.com/KB/aspnet/WatiN.aspx 中的示例.不幸的是,我遇到了一个问题,它声称名称为“q”的文本字段
我的问题集中在我的设置目前是否遵循有关 BDD 和 UI 验收测试的最佳实践方法。我正在使用 WatiN 和 SpecFlow 来构建我的 UI 验收测试,我正在将我的应用程序部署到 AppHarbo
我正在使用WatiN进行Web应用程序测试。有一个称为回车选择的字段,在这里我需要通过按回车键一个接一个地添加三个值,即先添加第一个值,然后按回车键,再添加第二个值,然后按回车键,所以请建议我如何使用
我尝试通过Nugget安装SpecRun。运行功能时,出现以下错误: [ERROR] Get to the Contact Page: The CurrentThread needs to have
我收到以下 WatiN 错误: Unhandled Exception: System.IO.FileLoadException: Could not load file or assembl y '
我正在使用 watin 进行一些单元测试。但问题是当网页加载时间过长时,测试自动化会失败,因为所需的元素仍然不可用,但控制操作已经在 watin 中执行。 最佳答案 只需将 Settings.Wait
我正在尝试使用 Watind。我在登录页面 og 应用程序时遇到问题,它会自动重定向到主页(无需任何用户干预)。看起来 WatiN 在这方面有问题。 Wehn 我调用: IE ie = new IE(
我正在寻求有关IE 9和WatiN的问题的帮助时,发现几乎所有问题和答案都是在2011年进行的。当时,大多数回答的人都表示将很快发布更新以解决问题。然而,我们是在 2013 年,最后一次更新是在 20
我正在使用 WatiN 进行一些网络测试,但遇到了选择列表的问题。 我必须先浏览几页,添加一个“类别”元素,该元素将填充所述麻烦的选择列表。 我已经能够使用 ByValue 从列表中轻松选择一个元素,
我是一名优秀的程序员,十分优秀!