黄瓜、水豚和硒随机工作
使用黄瓜、水豚和硒进行设置,但某些场景只能随机运行。
跑步
rvm 上的 ruby 1.8.6
导轨2.3.8
selenium 弹出 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
黄瓜步骤:
鉴于我在注册页面
我在“user_login”中填写“[电子邮件受保护]”身体”
我在“body”中用“secret”填写“user_password”
我在“body”中用“secret”填写“user_password_confirmation”
我检查“body”中的“terms_of_use”
我按“body”内的“create_user_button”
任何见解都会很棒:)
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
The error output is sometimes:
> 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'
And othertimes:
> 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....
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
Cucumber-steps:
Given I am on the signup page
And I fill in "user_login" with "[email protected]" 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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是 HTTP 模拟,如果您从环境中(完全)删除 fakeweb 或 webmock,它应该会再次工作。
亚当·格林 (Adam Greene) 的最后评论对于设置 Curb 确实有效:
Selenium::WebDriver.for :firefox, :http_client => Selenium::WebDriver::Remote::Http::Curb
阅读 Capybara 组的帖子。
我们遇到的问题是使用 fakeweb 或 webmock 回放记录的 http 流量,因为 Web 驱动程序现在是 Curb。因此,如果您的目标是伪造 Capybara 上的流量,您将使浏览器测试再次正常工作,但您将无法在同一浏览器上播放流量。 (我们使用 VCR 进行录制。)
添加 Curb 支持在 Fakeweb 的 Github Issues 网站上被列为“门票”。
It's HTTP mocking, if you remove fakeweb or webmock from your environment (entirely), it should all work again.
The last comment by Adam Greene DOES WORK regarding setting up Curb with:
Selenium::WebDriver.for :firefox, :http_client => Selenium::WebDriver::Remote::Http::Curb
Read the thread on the Capybara group.
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.)
Adding Curb support is listed as a "ticket" on the Fakeweb's Github Issues site.
我最近在使用 cucumber/capybara/akephalos/fakeweb 的 Rails 2.3 应用程序中遇到了这个问题,但最终通过完全杀死我的包中的所有 gem(它们保存在
.bundle/
中)并重新安装来解决这个问题。I bumped into this in a Rails 2.3 app with cucumber/capybara/akephalos/fakeweb recently, but ultimately got to resolve this by completely killing all gems in my bundle (they where kept in
.bundle/
and reinstalling.