【问题标题】:Watin and Fluent automation - reference to current browserWatin 和 Fluent 自动化 - 对当前浏览器的引用
【发布时间】:2012-08-13 17:04:03
【问题描述】:

我在我的项目中使用 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;

有什么想法吗?

提前谢谢你!

【问题讨论】:

    标签: automated-tests watin functional-testing fluentautomation


    【解决方案1】:

    仅供以后可能会发现此内容的任何人参考。作为Fluent Automation GitHub Issue 的一部分,我们讨论了如何处理此问题,并提供了几种不同的解决方案。

    理想情况下,任何用户交互都将使用实际的I.Click("#button") 类型操作来处理,但在像这样的边缘情况下,您有类似基于插件/flash/java/you-name-it 的 UI 元素,您要么需要到:

    1. 添加一个扩展方法来支持这一点,就像 lstanczyk 所做的那样,或者
    2. 在不可见或屏幕外的元素上执行点击事件之类的操作,通过 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。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-14
      • 2011-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-22
      • 1970-01-01
      • 2011-04-14
      相关资源
      最近更新 更多