【发布时间】:2012-04-03 01:44:15
【问题描述】:
我一直在尝试开始使用 Cucumber 和 Watir。我已经完成了安装并编写/复制了一个简单的“功能”。但是,我无法检查页面上的内容。
这是我的功能:
功能:Google 搜索 为了确保人们可以找到我的文档 我想检查它是否列在 Google 的第一页
Scenario: Searching for JS.Class docs
Given I have opened "http://www.google.com/"
When I search for "JS.Class"
Then I should see a link to "http://jsclass.jcoglan.com/" with text "JS.Class v3.0"
我的 env.rb 文件看起来像这样
require 'watir'
require 'rspec'
这是我的 search_steps.rb
@ie
Given /^I have opened "([^\"]*)"$/ do |url|
@ie = Watir::IE.new
@ie.goto(url)
end
When /^I search for "([^\"]*)"$/ do |arg1|
@ie.text_field(:name, "q").set(arg1)
@ie.button(:name, "btnG").click
end
Then /^I should see a link to "([^\"]*)" with text "([^\"]*)"$/ do |arg1, text|
puts arg1
# @ie.text.should include(arg1)
@ie.close
end
当我取消注释“@ie.text.should include(arg1)”行时,我会抛出此错误。
Then I should see a link to "http://jsclass.jcoglan.com/" with text "JS.Class v3.0" # features/step_definitions/search_steps.rb:13
true
undefined method `split' for ["http://jsclass.jcoglan.com/"]:Array (NoMethodError)
./features/step_definitions/search_steps.rb:17:in `/^I should see a link to "([^\"]*)" with text "([^\"]*)"$/'
features\search.feature:8:in `Then I should see a link to "http://jsclass.jcoglan.com/" with text "JS.Class v3.0"'
失败的场景: cucumber features\search.feature:5 # 场景:搜索 JS.Class 文档
现在 Then 函数没有发挥作用。如果我注释掉这一行,那么它真正做的就是写出一些文本。
我拥有的 gem 包括以下 cucumber 、rspec 、watir 和 watir-webdriver
我拥有的 ruby 版本是:ruby 1.9.3p125。
我在 Windows 7 Ultimate 上运行它。
我想知道我是否缺少宝石或其他东西。阅读该消息意味着我正在调用它找不到的方法,但我在网络上找到了很多使用此方法的页面。
非常欢迎任何正确方向的帮助、指导或指示。
【问题讨论】:
-
您可以使用
--backtrace开关运行 Cucumber 并发布完整的错误消息吗?它应该可以更好地了解异常的来源。