2

我在我的项目中使用Fluent Automation来创建更多人类可读的测试。信息可以在这里http://fluent.stirno.com/并在GitHub上:https://github.com/stirno/FluentAutomationWatin和Fluent自动化 - 对当前浏览器的参考

我需要能够执行一些事情,不与流畅的自动化实现,并希望能够得到浏览器或华廷元素的保持。我其实是想运行一个LINQ查询像这样:

var indicators = from i in this.CurrentBrowser.Links 
where i.Url.Contains("LeadsMine.aspx?flag") 
select i; 

任何想法?

预先感谢您!

回答

2

仅供参考,任何人可能会在稍后找到。作为Fluent Automation GitHub Issue的一部分,我们讨论了如何处理这个问题,并提供了几种不同的解决方案。

理想情况下,任何用户交互都将使用实际的I.Click("#button")类型操作进行处理,但在类似此类的边缘情况下,您可能需要插件/ flash/java /基于名称的UI元素:

  1. 添加一个扩展方法来支持这一点,因为lstanczyk做,或
  2. 这样做click事件上的不可见或关闭屏幕元素,触发一个JavaScript的API与合作一个onclick插入。

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为字符串。