Sha256: 0d185fcc6fc679c19e4e3004bc0f0e22fe72373923460c7f3fade4e059bfa1b8
Contents?: true
Size: 994 Bytes
Versions: 1
Compression:
Stored size: 994 Bytes
Contents
# frozen_string_literal: true 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 :text attr_accessor :title # Store state of page when it is loaded # @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:') } emails.collect! { |link| link.href.split(':').last } 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
generic_test-0.2.2 | lib/generic_test/page.rb |