以下は私のスクリプトです。以下のコード コメントで述べたように、browser.text.include?(item).should == true
fromを実行すると、予想される Web ページ コンテンツを検索するときに返されるcmd prompt -> irb
値が正しく取得されます。true
ただし、このスクリプトで実行すると、機能せず、 の値が返されますfalse
。興味深いことに、スクリプトを変更するbrowser.html.include?(item).should == true
と、スクリプトと cmd プロンプトの両方で機能します。どうした?
Ruby 1.9.3 と以下にリストされている宝石を使用しています。どんな助けでも素晴らしいでしょう!! ありがとうございました!!
require 'watir-webdriver'
require 'rspec'
require 'rubygems'
Given(/^that I have gone to the Google page$/) do
@browser = Watir::Browser.new :ff
@browser.goto "http://www.google.com"
end
When(/^I add "(.*)" to the search box$/) do |item|
@browser.text_field(:name => "q").set(item)
end
And(/^click the Search Button$/) do
@browser.button(:name => "btnG").click
end
Then(/^"(.*)" should be mentioned in the results$/) do |item|
@browser.text.include?(item).should == true
#the line directly above works in cmd prompt -> irb -> and returns a value of true
#but when executed from this script returns a value of false and shows up as failed in the
#cucumber html report
@browser.close
end