我试图只在纯Ruby中运行没有Rails,Cucumber,Rspec的Capybara。
我的测试脚本如下所示:
require 'capybara'
require 'selenium-webdriver'
url = "MyAccessKey"
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
capabilities.platform = :LINUX
Capybara.register_driver :sauce do |app|
Capybara::Selenium::Driver.new(app,
:browser => :remote, :url => url,
:desired_capabilities => capabilities)
end
Capybara.default_driver=:sauce
Capybara.app_host="127.0.0.1:8888"
include Capybara::DSL
# include Capybara::RSpecMatchers
visit('')
feature "Signing in" do
scenario "Should sign in" do
within ('#form_content') do
fill_in 'login',:with=>'user'
fill_in 'password',:with=>'pwd'
find(:xpath,'//input[@type="submit"]').click
end
end
end
visit
正常工作...但是feature and scenario
给出了NoMethodError。我应该在这里包括什么吗? 最佳答案
feature
和scenario
是RSpec的一部分。使用Capybara时,默认情况下不会加载此文件。
假设您要包括Capybara修改过的RSpec,而不是这样做:
require 'capybara'
做:
require 'capybara/rspec'
如果您只需要简单的RSpec,则可以执行以下操作:
require 'capybara'
require 'rspec'
关于ruby-on-rails - 没有Rails,Rspec或 cucumber 的 capybara NoMethoderror,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20421813/