Class: Insite::UndefinedPage

Inherits:
Object
  • Object
show all
Extended by:
ComponentMethods
Includes:
CommonMethods, ComponentInstanceMethods
Defined in:
lib/insite/page/undefined_page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CommonMethods

#document, #inspect, #update_object

Constructor Details

#initialize(site) ⇒ UndefinedPage

Returns a new instance of UndefinedPage.



44
45
46
47
48
# File 'lib/insite/page/undefined_page.rb', line 44

def initialize(site)
  @site    = site
  @browser = process_browser
  @url     = @site.browser.url
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mth, *args, &block) ⇒ Object

TODO: Do the same cache check that’s done for a defined page and reapply the method if the cache is updated and the new page DOES respond to the method.

Raises:

  • (NoMethodError)


52
53
54
55
# File 'lib/insite/page/undefined_page.rb', line 52

def method_missing(mth, *args, &block)
  raise NoMethodError, "Could not apply #{mth}. The current page could not be " \
  "recognized. Current URL #{@browser.url}"
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



3
4
5
# File 'lib/insite/page/undefined_page.rb', line 3

def arguments
  @arguments
end

#browserObject (readonly)

Returns the value of attribute browser.



3
4
5
# File 'lib/insite/page/undefined_page.rb', line 3

def browser
  @browser
end

#has_fragmentObject (readonly)

Returns the value of attribute has_fragment.



3
4
5
# File 'lib/insite/page/undefined_page.rb', line 3

def has_fragment
  @has_fragment
end

#page_attributesObject (readonly)

Returns the value of attribute page_attributes.



3
4
5
# File 'lib/insite/page/undefined_page.rb', line 3

def page_attributes
  @page_attributes
end

#page_elementsObject (readonly) Also known as: component_elements

Returns an empty Array (since the page hasn’t been defined.)



70
71
72
# File 'lib/insite/page/undefined_page.rb', line 70

def page_elements
  @page_elements
end

#page_featuresObject (readonly)

Returns the value of attribute page_features.



3
4
5
# File 'lib/insite/page/undefined_page.rb', line 3

def page_features
  @page_features
end

#page_urlObject (readonly)

Returns the value of attribute page_url.



3
4
5
# File 'lib/insite/page/undefined_page.rb', line 3

def page_url
  @page_url
end

#query_argumentsObject (readonly)

Returns the value of attribute query_arguments.



3
4
5
# File 'lib/insite/page/undefined_page.rb', line 3

def query_arguments
  @query_arguments
end

#required_argumentsObject (readonly)

Returns the value of attribute required_arguments.



3
4
5
# File 'lib/insite/page/undefined_page.rb', line 3

def required_arguments
  @required_arguments
end

#siteObject (readonly)

Returns the value of attribute site.



3
4
5
# File 'lib/insite/page/undefined_page.rb', line 3

def site
  @site
end

#url_matcherObject (readonly)

Returns the value of attribute url_matcher.



3
4
5
# File 'lib/insite/page/undefined_page.rb', line 3

def url_matcher
  @url_matcher
end

#url_templateObject (readonly)

Returns the value of attribute url_template.



3
4
5
# File 'lib/insite/page/undefined_page.rb', line 3

def url_template
  @url_template
end

Instance Method Details

#defined?Boolean

Always returns false.

Returns:

  • (Boolean)


11
12
13
# File 'lib/insite/page/undefined_page.rb', line 11

def defined?
  false
end

#describeObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/insite/page/undefined_page.rb', line 15

def describe
  puts <<-EOF
  Page Class:\t#{name} (#{__FILE__})
  URL Template:\tNA
  URL Matcher:\tNA

  Page class for any page that hasn't been defined (or that Insite doesn't recognize.)

  Note: If there is a page class that is defined for this page that isn't getting
  loaded, try the following:
   - Review the pages URL template for problems. A URL template is *not* an interpolated
 string -- it just looks like one. See the documentation for more details.
   - If the URL template seems to be designed correctly for loading the page, but the
 page's URL changes after the load, you will need to look at adding a URL matcher,
 which overrides the URL template for purposes of checking whether the page object
 is matching the currently displayed page after it has been loaded.

  Page Elements:\tNA
  EOF
end

#driverObject



36
37
38
# File 'lib/insite/page/undefined_page.rb', line 36

def driver
  @browser.driver
end

#htmlObject



40
41
42
# File 'lib/insite/page/undefined_page.rb', line 40

def html
  @browser.html
end

#nokogiriObject

Returns a Nokogiri object for the page HTML.



58
59
60
# File 'lib/insite/page/undefined_page.rb', line 58

def nokogiri
  @site.nokogiri
end

#on_page?Boolean

Similar to the method that you can call on a page object you’ve defined (but always returns false since the Undefined page class is only returned when the current page doesn’t match up to any page that you’ve actually defined.

Returns:

  • (Boolean)


65
66
67
# File 'lib/insite/page/undefined_page.rb', line 65

def on_page?
  false
end

#titleObject

Returns the page title displayed by the browser.



81
82
83
# File 'lib/insite/page/undefined_page.rb', line 81

def title
  @browser.title
end

#urlObject

Returns the current URL.



76
77
78
# File 'lib/insite/page/undefined_page.rb', line 76

def url
  @browser.url
end