我在项目中使用 Fluent Automation 来创建更多人类可读的测试。此处提供信息 http://fluent.stirno.com/并在 GitHub 上:https://github.com/stirno/FluentAutomation
我需要能够执行一些未通过流畅自动化实现的操作,并且希望能够掌握浏览器或 WatiN 元素。我实际上正在尝试运行 LINQ 查询,如下所示:
var indicators = from i in this.CurrentBrowser.Links
where i.Url.Contains("LeadsMine.aspx?flag")
select i;
有什么想法吗?
提前谢谢您!
最佳答案
仅供以后可能发现此内容的人引用。作为Fluent Automation GitHub Issue的一部分,我们讨论了如何处理这个问题。 ,有几个不同的解决方案。
理想情况下,任何用户交互都将使用实际的 I.Click("#button")
类型操作来处理,但在像这样的边缘情况下,您有类似 plugin/flash/java 的东西基于/you-name-it 的 UI 元素,您需要:
- 添加扩展方法来支持此功能,如 lstanczyk 所做的那样,或者
- 在不可见或屏幕外的元素上执行诸如单击事件之类的操作,并通过 onclick 触发 JavaScript API 来与插件配合使用。
lstanczyk 自己的解决方案是添加一个扩展方法:
public static void RunScript(this FluentAutomation.Interfaces.INativeActionSyntaxProvider I, string scriptCode)
{
FluentAutomation.Element bodyTag = I.Find("body").Invoke() as FluentAutomation.Element;
bodyTag.AutomationElement.DomContainer.RunScript(scriptCode);
}
然后使用 I.RunScript(script);
调用它,其中 script
是字符串中的 JavaScript。
关于automated-tests - Watin 和 Fluent 自动化 - 引用当前浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11938938/