I am trying to use page-object gem in my watir-webdriver scripts and I think I might be missing something.
Here is my code for log_in.rb: require "./all_deals"
class LogIn
include PageObject
text_field(:email, :id => 'UserName')
text_field(:password, :id => 'Password')
checkbox(:remember_me, :id => 'RememberMe')
button(:log_me_in, :value => 'Login')
def initialize(browser)
@browser = browser
end
def log_in (email, password)
self.email = email
self.password = password
remember_me
log_me_in
AllDeals.new(@browser)
end
end
My home_page.rb
require "./log_in"
class HomePage
def initialize(browser)
@browser = browser
end
def visit
@browser.goto "http://treatme.co.nz/"
end
def go_to_log_in
@browser.goto "https://treatme.co.nz/Account/LogOn"
LogIn.new(@browser)
end
end
Here is my log_in_test.rb
require "rubygems"
require "test/unit"
require "watir-webdriver"
require "page-object"
require "./home_page"
class LogInTest < Test::Unit::TestCase
def setup
@browser ||= Watir::Browser.new :firefox
end
def teardown
@browser.close
end
def test_fail
@home_page = HomePage.new(@browser)
@home_page.visit
@log_in_page = @home_page.go_to_log_in
@all_deals = @log_in_page.log_in("test@gmail.com","test")
assert (@all_deals.get_title == "GrabOne Daily Deals - Buy Together, Save Together")
end
end
The result of the test run is:
Finished tests in 22.469286s, 0.0445 tests/s, 0.0000 assertions/s.
1) Error:
test_fail(LogInTest):
NoMethodError: undefined method `text_field_value_set' for nil:NilClass
C:/Ruby193/lib/ruby/gems/1.9.1/gems/page-object-0.9.2/lib/page-object/accessors.rb:142:in `block in text_field'
I am using Ruby 1.9 with page-object gem 0.9.2.
Can you please help me?
Also in each of those rb file, I need to require the class files it references, is there a way I don't have to declare it every time?
Thanks so much.