Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Cucumber和Webrat/Selenium的页面对象模式?_Selenium_Cucumber_Webrat - Fatal编程技术网

如何使用Cucumber和Webrat/Selenium的页面对象模式?

如何使用Cucumber和Webrat/Selenium的页面对象模式?,selenium,cucumber,webrat,Selenium,Cucumber,Webrat,我正在看一个黄瓜测试套件,它现在有点脆弱;很多小步骤,而且不了解页面本身 我想在一系列Selenium PageObject中分析步骤定义中涉及的逻辑 然而,因为我使用的是Webrat而不是Selenium,所以一切都必须通过Webrat模型。所以我做不到 class MyPage < Selenium::WebPage end class MyPage

我正在看一个黄瓜测试套件,它现在有点脆弱;很多小步骤,而且不了解页面本身

我想在一系列Selenium PageObject中分析步骤定义中涉及的逻辑

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

class MyPage < Selenium::WebPage

end
class MyPage
因为这增加了直接依赖性


因此,我必须通过Webrat路由所有内容,同时仍然保持Selenium页面对象。我看不到关于这方面的文档:如果有人在Webrat+PageModel上有任何东西,我很想看看。

结果是:

class MyPage < BasePage
  def visit
    @world.visit "/"
  end

end

class BasePage
  def initialize(world)
    @world = world
  end
end

我们刚刚发布了一些听起来像你想要的东西。 看看Gizmo- 与(webrat | capybara),(cucumber | rspec)等合作

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