Class: GenericTest::Page
- Inherits:
-
Object
- Object
- GenericTest::Page
- Defined in:
- lib/generic_test/page.rb
Overview
Represents a web page state at a particular point of time
Instance Attribute Summary collapse
-
#emails ⇒ Array
List of emails.
-
#html ⇒ Object
Returns the value of attribute html.
-
#internal_links ⇒ Array
List of urls that include domain being tested.
-
#links ⇒ Array
List of links elements on the page.
-
#text ⇒ Object
Returns the value of attribute text.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(browser) ⇒ Page
constructor
Store state of page when it is loaded.
Constructor Details
#initialize(browser) ⇒ Page
Store state of page when it is loaded
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/generic_test/page.rb', line 19 def initialize(browser) self.emails, self.links = browser.links.partition do |link| link.href.start_with?('mailto:') end links.reject! { |link| link.href.empty? || link.href.start_with?('javascript:') || link.href.include?('tel:') } emails.collect! { |link| link.href.split(':').last } self.internal_links = links.filter do |link| link.href.include? ENV["PAGE_URL"] end.collect { |link| link.href }.uniq self.url = browser.url self.html = browser.html self.text = browser.text self.title = browser.title puts "Found #{links.count} links, #{emails.count} emails at #{url} (#{title})" end |
Instance Attribute Details
#emails ⇒ Array
Returns List of emails.
11 12 13 |
# File 'lib/generic_test/page.rb', line 11 def emails @emails end |
#html ⇒ Object
Returns the value of attribute html.
13 14 15 |
# File 'lib/generic_test/page.rb', line 13 def html @html end |
#internal_links ⇒ Array
Returns List of urls that include domain being tested.
9 10 11 |
# File 'lib/generic_test/page.rb', line 9 def internal_links @internal_links end |
#links ⇒ Array
Returns List of links elements on the page.
7 8 9 |
# File 'lib/generic_test/page.rb', line 7 def links @links end |
#text ⇒ Object
Returns the value of attribute text.
14 15 16 |
# File 'lib/generic_test/page.rb', line 14 def text @text end |
#title ⇒ Object
Returns the value of attribute title.
15 16 17 |
# File 'lib/generic_test/page.rb', line 15 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
12 13 14 |
# File 'lib/generic_test/page.rb', line 12 def url @url end |