class Page

Attributes

browser[RW]
elements[RW]
name[RW]
title[RW]
url[RW]

Public Class Methods

new(browser, pageobject) click to toggle source
# File lib/core/PageObject.rb, line 318
def initialize(browser, pageobject)
        @browser = browser
        @name = pageobject['page']['name']
        @url = pageobject['page']['url']
        @title = pageobject['page']['title']

        @elements = Hash.new

        if pageobject.key? 'elements'
                for object in pageobject['elements']
                        element = Element.new(self, object)

                        if @elements.key? element.name
                                Log.Info "#{@name}\nDuplicate element name: '#{element.name}'"
                        else
                                @elements[element.name] = element
                        end
                end
        end
end

Public Instance Methods

FindElement(name) click to toggle source
# File lib/core/PageObject.rb, line 349
def FindElement(name)
        if @elements.key? name
                return @elements[name]
        end

        raise "Element not found in list: '#{name}'\n"
        return nil
end
Go() click to toggle source
# File lib/core/PageObject.rb, line 339
def Go()
        begin
                @browser.goto @url
        rescue Timeout::Error
                raise "Page load timeout\nURL: #{@url} (15 sec)\n"
        end

        return true
end
VerifyTitle() click to toggle source
# File lib/core/PageObject.rb, line 358
def VerifyTitle()
        @browser.windows.last.use

        if @title == @browser.title
                return true
        end

        Log.Failed("Title not matched", @browser.title, @title)
        return false
end
VerifyURL() click to toggle source
# File lib/core/PageObject.rb, line 369
def VerifyURL()
        @browser.windows.last.use

        uri = URI(@url)
        url = "#{uri.scheme}://#{uri.host}#{uri.path}"
        
        begin
                Watir::Wait.until(15) { browser.url.include? url }
                return true
        rescue
                Log.Failed("URL not matched", @browser.url, url)
                return false
        end
end