【问题标题】:How to use Page Object pattern with Cucumber and Webrat / Selenium?如何将页面对象模式与 Cucumber 和 Webrat / Selenium 一起使用?
【发布时间】:2011-02-04 14:41:26
【问题描述】:

我正在研究一个现在有点脆弱的黄瓜测试套件;很多小步骤,对页面本身一无所知。

我想分解出一系列 Selenium PageObjects 中步骤定义所涉及的逻辑。 As seen here.

但是,因为我使用的是 Webrat 而不是 Selenium,所以一切都必须通过 Webrat 模型。所以我做不到

class MyPage < Selenium::WebPage

end

因为这增加了一个直接的依赖关系。

所以我必须通过 Webrat 路由所有内容,同时仍然保持 Selenium Page 对象的优点。我看不到这方面的任何文档:如果有人在 Webrat + PageModel 上有任何东西,我很乐意看到它。

【问题讨论】:

    标签: selenium cucumber webrat


    【解决方案1】:

    原来答案是:

    class MyPage < BasePage
      def visit
        @world.visit "/"
      end
    
    end
    
    class BasePage
      def initialize(world)
        @world = world
      end
    end
    

    然后在一个步骤定义中:

    Given /I am awesome/ do
      page = MyPage.new(self)
      page.visit
    end
    

    【讨论】:

      【解决方案2】:

      我们刚刚发布了一些听起来就像你所追求的东西。 看看 Gizmo - http://rubygems.org/gems/gizmo/ 与 (webrat | capybara)、(cucumber | rspec) 等一起使用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-11-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-07
        • 1970-01-01
        • 2010-12-31
        相关资源
        最近更新 更多