lib/generic_test/page.rb in generic_test-0.1.9 vs lib/generic_test/page.rb in generic_test-0.1.10
- old
+ new
@@ -1,20 +1,26 @@
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 emails
+ attr_accessor :emails
attr_accessor :url
attr_accessor :html
attr_accessor :title
# Store state of page when it is loaded
# @param [Watir::Browser] browser Watir browser
def initialize(browser)
- self.links = browser.links
+ self.emails, self.links = browser.links.partition do |link|
+ link.href.start_with?('mailto:')
+ end
+ links.reject! { |link| link.href.empty? }
+ emails.collect! { |link| link.href.split(':').last }
self.url = browser.url
self.html = browser.html
self.title = browser.title
- puts "Found #{links.count} links at #{url} (#{title})"
+ puts "Found #{links.count} links, #{emails.count} emails at #{url} (#{title})"
end
end
end