黄瓜,水豚和硒随机工作

安装黄瓜,水豚和硒,但一些情况只能随机使用。
运行
红宝石1.8.6上rvm
导轨2.3.8
硒弹出打开Firefox 3.6

我试图添加这个没有运气:

with_scope(selector) do
  click_button(button)
  selenium.wait_for_page_to_load
end

错误输出有时是:

>  Given I am logged in and have created newsletter and subscribers                           # features/step_definitions/newsletter_send_steps.rb:108
      end of file reached (EOFError)
      /Users/christianhager/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/1.8/net/protocol.rb:133:in `sysread'
      /Users/christianhager/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/1.8/net/protocol.rb:133:in `rbuf_fill'
      /Users/christianhager/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/1.8/timeout.rb:62:in `timeout'
      /Users/christianhager/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/1.8/timeout.rb:93:in `timeout'
      /Users/christianhager/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
      /Users/christianhager/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
      /Users/christianhager/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/1.8/net/protocol.rb:126:in `readline'
      /Users/christianhager/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/1.8/net/http.rb:2020:in `read_status_line'
      /Users/christianhager/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/1.8/net/http.rb:2009:in `read_new'
      /Users/christianhager/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/1.8/net/http.rb:1050:in `request_without_fakeweb'
      /Users/christianhager/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/1.8/net/http.rb:1037:in `request_without_fakeweb'
      /Users/christianhager/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/1.8/net/http.rb:543:in `start'
      /Users/christianhager/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/1.8/net/http.rb:1035:in `request_without_fakeweb'
      ./features/step_definitions/web_steps.rb:24:in `__instance_exec2'
      ./features/step_definitions/web_steps.rb:9:in `with_scope'
      ./features/step_definitions/web_steps.rb:9:in `with_scope'
      ./features/step_definitions/web_steps.rb:23:in `/^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/'
      features/enhanced/newsletter_send1.feature:7:in `Given I am logged in and have created newsletter and subscribers'

和其他时间:

> no button with value or id or text 'create_user_button' found (Capybara::ElementNotFound)
      ./features/step_definitions/web_steps.rb:24:in `__instance_exec2'
      ./features/step_definitions/web_steps.rb:9:in `with_scope'
      ./features/step_definitions/web_steps.rb:9:in `with_scope'
      ./features/step_definitions/web_steps.rb:23:in `/^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/'
      features/enhanced/newsletter_send1.feature:7:in `Given I am logged in and have created newsletter and subscribers'

有时它只是起作用....

这就是我的env.rb的样子

ENV["RAILS_ENV"] ||= "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')

require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
require 'cucumber/rails/world'
require 'cucumber/rails/active_record'
require 'cucumber/web/tableish'
require 'capybara/rails'
require 'capybara/cucumber'
require 'capybara/session'
require 'cucumber/rails/capybara_javascript_emulation' 
require "selenium-webdriver"

Capybara.default_driver = :selenium
Capybara.default_wait_time = 5 
Capybara.ignore_hidden_elements = false
Capybara.default_selector = :css

ActionController::Base.allow_rescue = false

require 'database_cleaner'
DatabaseCleaner.strategy = :truncation

Before do
 Capybara.reset_sessions!
 DatabaseCleaner.clean
end

Cucumber::Rails::World.use_transactional_fixtures = false

黄瓜步骤:
鉴于我在注册页面上
我在“body”中填写“user_login”和“jeppsipeppsi@arcticelvis.com”
我在“body”内填写“user_password”和“secret”
我在“body”中填写“secret_”的“user_password_confirmation”
我在“body”中检查“terms_of_use”
我在“body”内按下“create_user_button”

任何洞察力将是伟大的:)


这是HTTP嘲弄,如果你从你的环境中(完全)删除假网站或WebMock,它应该再次工作。

Adam Greene最后的评论是关于设置Curb的:Selenium :: WebDriver.for:firefox,:http_client => Selenium :: WebDriver :: Remote :: Http :: Curb

阅读Capybara集团的主题。

我们遇到的问题是使用fakeweb或webmock播放记录的http流量,因为网络驱动程序现在是Curb。 因此,如果您的目标是通过Capybara伪造流量,您将再次使用浏览器测试,但您无法通过同一浏览器播放流量。 (我们使用录像机录制。)

添加限制支持在Fakeweb的Github问题网站上列为“门票”。


我最近在一个Rails 2.3应用程序中碰到了这个应用程序,最近用黄瓜/水豚/ akephalos / fakeweb,但最终通过彻底杀死我捆绑的所有宝石来解决这个问题(它们保存在.bundle/重新安装中)。

链接地址: http://www.djcxy.com/p/1009.html

上一篇: cucumber, capybara & selenium works randomly

下一篇: django filter icontains match whole words only