Class: Spider::Test::PageObject
- Inherits:
-
Object
- Object
- Spider::Test::PageObject
- Defined in:
- lib/spiderfw/test/page_object.rb
Instance Attribute Summary (collapse)
-
- (Object) browser
readonly
Returns the value of attribute browser.
Instance Method Summary (collapse)
- - (Object) go(url)
-
- (PageObject) initialize(browser = nil)
constructor
A new instance of PageObject.
- - (Object) method_missing(method, *args)
Constructor Details
- (PageObject) initialize(browser = nil)
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
- (Object) method_missing(method, *args)
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
- (Object) browser (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
- (Object) go(url)
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 |