Class: Spider::Test::PageObject
- Defined in:
- lib/spiderfw/test/page_object.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Returns the value of attribute browser.
Instance Method Summary collapse
- #go(url) ⇒ Object
-
#initialize(browser = nil) ⇒ PageObject
constructor
A new instance of PageObject.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(browser = nil) ⇒ PageObject
Returns a new instance of PageObject.
6 7 8 9 10 11 12 13 |
# File 'lib/spiderfw/test/page_object.rb', line 6 def initialize(browser=nil) unless browser if Object.const_defined?(:Capybara) && Capybara.current_session browser = Capybara.current_session end end @browser = browser end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
22 23 24 |
# File 'lib/spiderfw/test/page_object.rb', line 22 def method_missing(method, *args) @browser.send(method, *args) end |
Instance Attribute Details
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
4 5 6 |
# File 'lib/spiderfw/test/page_object.rb', line 4 def browser @browser end |
Instance Method Details
#go(url) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/spiderfw/test/page_object.rb', line 15 def go(url) if url =~ /^https?:\/\/([^\/])(\/.+)$/ url = $1 end @browser.visit(url) end |