Sha256: 174f7026d2ca18e465bffbc80960334c8e19b3e15d5d2d39996a07aa2376487e

Contents?: true

Size: 912 Bytes

Versions: 12

Compression:

Stored size: 912 Bytes

Contents

# frozen_string_literal: true

module Webdrone
  class Browser
    def wait
      @wait ||= Wait.new self
    end
  end

  class Wait
    attr_accessor :ignore
    attr_reader :a0

    def initialize(a0)
      @a0 = a0
      @ignore = []
      @ignore << Selenium::WebDriver::Error::StaleElementReferenceError
      @ignore << Selenium::WebDriver::Error::NoSuchElementError
      @ignore << Selenium::WebDriver::Error::NoSuchFrameError
      @ignore << Selenium::WebDriver::Error::InvalidSelectorError
    end

    def for
      if @a0.conf.timeout
        Selenium::WebDriver::Wait.new(timeout: @a0.conf.timeout, ignore: @ignore).until do
          yield
        end
      else
        yield
      end
    rescue StandardError => error
      Webdrone.report_error(@a0, error)
    end

    def time(val)
      sleep val
    rescue StandardError => error
      Webdrone.report_error(@a0, error)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
webdrone-1.16.2 lib/webdrone/wait.rb
webdrone-1.16.0 lib/webdrone/wait.rb
webdrone-1.14.0 lib/webdrone/wait.rb
webdrone-1.12.0 lib/webdrone/wait.rb
webdrone-1.10.0 lib/webdrone/wait.rb
webdrone-1.8.12 lib/webdrone/wait.rb
webdrone-1.8.10 lib/webdrone/wait.rb
webdrone-1.8.8 lib/webdrone/wait.rb
webdrone-1.8.6 lib/webdrone/wait.rb
webdrone-1.8.4 lib/webdrone/wait.rb
webdrone-1.8.2 lib/webdrone/wait.rb
webdrone-1.8.0 lib/webdrone/wait.rb