黄瓜,水ara&硒随机 [英] cucumber, capybara & selenium works randomly

查看:170
本文介绍了黄瓜,水ara&硒随机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置黄瓜,水豚和硒,但一些情况只是随机工作。

Running
ruby​​ 1.8.6 on rvmogle
rails 2.3.8

selenium popps open firefox 3.6


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

Setup with cucumber, capybara and selenium but some scenarios works only randomly.
Running
ruby 1.8.6 on rvm
rails 2.3.8
selenium pops open firefox 3.6

I have tried to add this with no luck:

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'

有时它只是工作。 ..

And sometimes it just works....

这是我的env.rb的样子。

This is how my env.rb looks like

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

黄瓜步骤:

考虑到我在注册页面

并且我用jeppsipeppsi @ arcticelvis填写user_login。 comwithinbody_
我在body中填写user_password,并输入secret_
然后我用secret_password_confirmation body

并且检查body内的terms_of_use

并且在body内按create_user_button

Cucumber-steps:
Given I am on the signup page
And I fill in "user_login" with "jeppsipeppsi@arcticelvis.com" within "body"
And I fill in "user_password" with "secret" within "body"
And I fill in "user_password_confirmation" with "secret" within "body"
And I check "terms_of_use" within "body"
And I press "create_user_button" within "body"

任何洞察力都是巨大的:)

Any insight would be great :)

推荐答案

这是HTTP嘲笑,如果你删除fakeweb或webmock

It's HTTP mocking, if you remove fakeweb or webmock from your environment (entirely), it should all work again.

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

The last comment by Adam Greene DOES WORK regarding setting up Curb with: Selenium::WebDriver.for :firefox, :http_client => Selenium::WebDriver::Remote::Http::Curb

读取Capybara群组中的主题

我们遇到的问题是使用fakeweb或webmock回放记录的http流量,因为Web驱动程序现在是Curb。所以,如果你的目标是假装流量在水豚,你会得到浏览器测试重新工作,但你将无法播放通过同一浏览器的流量。 (我们使用VCR进行录制。)

The problem we're having is playing back recorded http traffic using fakeweb or webmock since web driver is now Curb. So if you're goal was to fake out traffic over Capybara, you'll get browser testing to work again but you won't be able to play the traffic back over the same browser. (We're using VCR to record.)

添加Curb支持在Fakeweb的Github Issues网站上列为票证。

Adding Curb support is listed as a "ticket" on the Fakeweb's Github Issues site.

这篇关于黄瓜,水ara&硒随机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆