lib/site-object/page.rb
# Navigates to the page that it's called on. Raises a SiteObject::PageNavigationNotAllowedError when
# navigation has been disabled for the page. Raises a SiteObject::WrongPageError if the
# specified page isn't getting displayed after navigation.
Navigates to the page that it's called on. Raises a SiteObject::PageNavigationNotAllowedError when
navigation has been disabled for the page. Raises a SiteObject::WrongPageError if the
specified page isn't getting displayed after navigation.
Navigates to the page that it ' s called on . Raises a SiteObject :: PageNavigationNotAllowedError when navigation has been disabled for the page . Raises a SiteObject :: WrongPageError if the specified page isn ' t getting displayed after navigation .
def visit
      if navigation_disabled?
        raise SiteObject::PageNavigationNotAllowedError, "Navigation has been disabled for the #{self.class.name} page. This was done when defining the page class and usually means that the page can't be reached directly through a URL and requires some additional work to access."
      end
      if @browser.is_a?(Watir::Browser)
        @browser.goto(@url)
      elsif @browser.is_a?(Selenium::WebDriver::Driver)
        @browser.get(@url)
      else
        raise SiteObject::BrowserLibraryNotSupportedError, "Only Watir-Webdriver and Selenium Webdriver are currently supported. Class of browser object: #{@browser.class.name}"
      end
      if @url_matcher
        raise SiteObject::WrongPageError, "Navigation check failed after attempting to access the #{self.class.name} page. Current URL #{@browser.url} did not match #{@url_template.pattern}. A URL matcher was also defined for the page and the secondary check against the URL matcher also failed. URL matcher: #{@url_matcher}" unless on_page?
      else
        raise SiteObject::WrongPageError, "Navigation check failed after attempting to access the #{self.class.name} page. Current URL #{@browser.url} did not match #{@url_template.pattern}" unless on_page?
      end
      @site.most_recent_page = self
      self
    end
def visit if navigation_disabled? raise SiteObject :: PageNavigationNotAllowedError , "Navigation has been disabled for the #{self.class.name} page. This was done when defining the page class and usually means that the page can't be reached directly through a URL and requires some additional work to access." end if @browser . is_a? ( Watir :: Browser ) @browser . goto ( @url ) elsif @browser . is_a? ( Selenium :: WebDriver :: Driver ) @browser . get ( @url ) else raise SiteObject :: BrowserLibraryNotSupportedError , "Only Watir-Webdriver and Selenium Webdriver are currently supported. Class of browser object: #{@browser.class.name}" end if @url_matcher raise SiteObject :: WrongPageError , "Navigation check failed after attempting to access the #{self.class.name} page. Current URL #{@browser.url} did not match #{@url_template.pattern}. A URL matcher was also defined for the page and the secondary check against the URL matcher also failed. URL matcher: #{@url_matcher}" unless on_page? else raise SiteObject :: WrongPageError , "Navigation check failed after attempting to access the #{self.class.name} page. Current URL #{@browser.url} did not match #{@url_template.pattern}" unless on_page? end @site . most_recent_page = self self end
Navigates to the page that it's called on.
Navigates to the page that it ' s called on .