lib/generic_test/page.rb in generic_test-0.2.2 vs lib/generic_test/page.rb in generic_test-0.3.0
- old
+ new
@@ -3,10 +3,12 @@
module GenericTest
# Represents a web page state at a particular point of time
class Page
# @return [Array] List of links
attr_accessor :links
+ # @return [Array] List of links that include domain being tested
+ attr_accessor :internal_links
# @return [Array] List of emails
attr_accessor :emails
attr_accessor :url
attr_accessor :html
attr_accessor :text
@@ -16,11 +18,14 @@
# @param [Watir::Browser] browser Watir browser
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.start_with?('tel:') }
+ 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})"