Reputation: 61
Using watir-webdriver, you can test your code while developing using IRB (interactive ruby). But this does not seem to work when using the page-object gem. When I run the ruby program, I can see my page-object calls are working. This is not apparent from IRB. E.g. Here's what I type in IRB:
require 'page-object'
require 'watir-webdriver'
b = Watir::Browser.new :chrome
I then manually navigate to the page I want and go back to IRB:
b.table(:id => 'manage-groups-list').present?
IRB returns true. So, watir-webdriver knows the table control is present on the page. Can we do the same thing in page-object? Continue coding in IRB:
class ManageGroupsPage
include PageObject
table(:groupsList, :id => 'manage-groups-list')
end
I then try to get the contents of the table from IRB. However, this returns an error:
irb(main):021:0> puts ManageGroupsPage.groupsList.to_s
NoMethodError: undefined method `groupsList' for ManageGroupsPage:Class
from (irb):21
from C:/Ruby193/bin/irb:12:in `<main>'
I am using page-object 1.0.3, watir-webdriver 0.6.11 and Ruby 1.9.3.
Upvotes: 1
Views: 204
Reputation: 1995
You can also use the 'pry' gem. Add to your env file, require 'pry'
and then where ever you want the code to stop/inspect, add binding.pry
Upvotes: 0
Reputation: 4982
Looking at their basic usage docs, it seems like calling
table :groupsList, id: 'manage-groups-list'
generates an instance method rather than a class method. So you would need to call the generated method like so:
b = Watir::Browser.new :chrome
page = ManageGroupsPage.new(b) # build a new page object
page.groupsList # call the instance method
Upvotes: 4