Class: Spider::Test::PageObject

Inherits:
Object
  • Object
show all
Defined in:
lib/spiderfw/test/page_object.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (PageObject) initialize(browser = nil)



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