作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我试图让 Capybara 在一个简单的 Ruby 脚本中运行——即没有/在 Rails 之外。这是脚本:
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
include Capybara
Capybara.current_driver = :selenium
Capybara.app_host = 'http://www.google.com'
visit('/')
问题是,当我运行它时,我得到了这个错误:
NameError: uninitialized constant Capybara::Session
at top level in dsl.rb at line 52
method gem_original_require in custom_require.rb at line 36
method require in custom_require.rb at line 36
at top level in capybara_test.rb at line 3
method gem_original_require in custom_require.rb at line 31
method require in custom_require.rb at line 31
at top level in capybara_test.rb at line
我做错了什么?
更多信息:
谢谢!
尼尔
注意:根据 jnicklas 的评论,我尝试了这个,它更接近于新的 README:
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
Capybara.default_driver = :selenium
Capybara.app_host = 'http://www.google.com'
module MyCapybaraTest
include Capybara
def test_google
visit('/')
end
end
不幸的是,我仍然看到同样的错误:
NameError: uninitialized constant Capybara::Session
想法?
谢谢!
最佳答案
下面是一些似乎对我有用的东西:
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
Capybara.run_server = false
Capybara.current_driver = :selenium
Capybara.app_host = 'http://www.google.com'
module MyCapybaraTest
class Test
include Capybara::DSL
def test_google
visit('/')
end
end
end
t = MyCapybaraTest::Test.new
t.test_google
关于ruby - 如何在纯 Ruby(无 Rails)中使用 Capybara?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3484169/
我是一名优秀的程序员,十分优秀!