首页 文章

* Windows *中的并行黄瓜/ Watir场景

提问于
浏览
3

有关我可以做什么/用于在Windows上并行运行黄瓜场景的任何想法?到目前为止,我已经尝试过(以下结果):

WatirGrid

必须使用Ruby线程实际以“并行”方式运行 . 这迫使我们将浏览器对象包装在一个线程中,因此一旦线程块关闭就无法访问 . (无法将Browser对象传递给黄瓜环境)

Hydra:

需要SSH(和公钥)访问远程盒子(即没有Windows)

Selenium Grid:

超重且找不到明确的黄瓜测试路径

TestJour:

需要Bonjour(不适用于Windows)

1 回答

  • 1

    重新 Watirgrid ...

    我已经添加了一个迭代方法,可以传递一组watir代码来执行远程浏览器对象 . 因此浏览器对象在步骤之间变得可重用 . 更新详细的黄瓜示例如下:

    https://github.com/90kts/watirgrid/blob/master/examples/cucumber/step_definitions/example_steps.rb

    你的cuke步骤最终看起来像这样:

    Given /^navigate to the portal$/ do
      @grid.iterate {|browser| browser.goto "http://gridinit.com/examples/logon.html" }
    end
    
    When /^they enter their credentials$/ do
      @grid.iterate do |browser|
        browser.text_field(:name => "email").set "tim@mahenterprize.com"
        browser.text_field(:name => "password").set "mahsecretz"
        browser.button(:type => "submit").click
      end
    end
    
    Then /^they should see their account settings$/ do
      @grid.iterate do |browser|
        browser.text.should =~ /Maybe I should get a real Gridinit account/
      end
    end
    

    如果您有任何问题,请随时给我留言 . 我们还有一个关于EC2的watirgrid的商业实现,可在http://gridinit.com/public/examples进行测试,敬请关注更多不同测试框架的更新!

    仅供参考,控制/迭代助手是最新版本的watirgrid v1.1.2

    对于每个提供商的不同场景 do it in parallel ,我只需要一个看起来像这样的支持/ env.rb:

    require 'watirgrid'
    require 'rspec/expectations';
    
    ENV["GRID"] = 'true'
    ENV["controller_uri"] = "druby://10.0.1.3:11235"
    
    if ENV["GRID"] then
      params = {}
      params[:controller_uri]   = ENV["controller_uri"]
      params[:browser]          = 'chrome' # type of webdriver browser to spawn
      grid ||= Watir::Grid.new(params)
      grid.start(:initiate => true, :quantity => 1, :take_all => true)
    else
      @browser ||= Watir::Browser.new :chrome
    end
    
    Before do |scenario|
      @browser = grid.providers.first
    end
    
    at_exit do
      grid.iterate do |browser|
        browser.close
      end
      grid.release_tuples
    end
    

    注意我正在使用 :take_all => true 获取对提供程序的独占访问权并将其释放回网格 at_exit ...然后我将使用CLI从单独的测试运行程序调用我的方案,可能包含在bash或DOS脚本中,例如

    cucumber features --name "Name of scenario 1"
    cucumber features --name "Name of scenario 2"
    cucumber features --name "Name of scenario 3"
    ...
    etc
    

相关问题