我试图让我的第一页对象工作。我是红宝石和黄瓜的新手,所以我不确定我做错了什么。到目前为止,它是一个非常简单的程序。我的目标是去谷歌搜索“培根”
我的支持文件夹中有我的 page_object 文件夹(我认为这应该是不确定的)
我觉得 include PageObject 没有正确地包含。
主页.rb
class HomePage
include PageObject
text_field(:search_box, :id=> 'gbqfq')
button(:search_button, :id=> 'btnG')
end
stepdefs.rb
Given /^on google$/ do
@BROWSER.goto 'www.google.com'
end
When /^i search for bacon$/ do
@home_page.search_for('Bacon')
end
Then /^BACON!!!!!!$/ do
@BROWSER.text.include? 'Bacon'
end
环境.rb
require 'watir-webdriver'
require 'rubygems'
require 'page-object/page_factory'
World(PageObject::PageFactory)
Before do
@BROWSER = Watir::Browser.new
@home_page = HomePage.new(@BROWSER)
end
宝石文件
source 'https://rubygems.org'
group :test do
gem 'cucumber'
gem 'watir'
gem 'page-object'
end
我得到的错误:
undefined method `text_field' for HomePage:Class (NoMethodError)
C:/ihateautomation/watir/features/support/page_objects/homepage.rb:6:in `<class:HomePage>'
C:/ihateautomation/watir/features/support/page_objects/homepage.rb:2:in `<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.10/lib/cucumber/rb_support/rb_language.rb:122:in `load'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-