Sha256: a97f0d799cff79ee97c80431e9c6c0a6967dc95301bae4a2c83d75cb0615d3c0
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
require "rspec/expectations" require 'howitzer/utils/locator_store' class WebPage BLANK_PAGE = 'about:blank' #TODO include Capybara DSL here include LocatorStore include RSpec::Matchers def self.open(url="#{settings.app_url}#{self::URL}") log.info "Open #{self.name} page by '#{url}' url" retryable(tries: 2, logger: log, trace: true, on: Exception) do |retries| log.info "Retry..." unless retries.zero? visit url end new end def self.given new end def wait_for_ajax(timeout=settings.timeout_small, message=nil) end_time = ::Time.now + timeout until ::Time.now > end_time return if page.evaluate_script('$.active') == 0 sleep 0.25 log.info "#{Time.now}" end log.error message || "Timed out waiting for ajax requests to complete" end def wait_for_url(expected_url, time_out=settings.timeout_small) wait_until(time_out) do operator = expected_url.is_a?(Regexp) ? :=~ : :== current_url.send(operator, expected_url).tap{|res| sleep 1 unless res} end rescue log.error "Current url: #{current_url}, expected: #{expected_url}" end def reload log.info "Reload '#{current_url}'" visit current_url end def self.current_url page.current_url end def self.text page.find('body').text end private def initialize wait_for_url(self.class::URL_PATTERN) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
howitzer-0.0.3 | lib/howitzer/web_page.rb |
howitzer-0.0.1 | lib/howitzer/web_page.rb |