Sha256: fdf46f97f9f70e7b64e872848ed7dacfb9cefecae8b9f4500691d3b2eed000fe

Contents?: true

Size: 897 Bytes

Versions: 2

Compression:

Stored size: 897 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(&block)
      if @a0.conf.timeout
        Selenium::WebDriver::Wait.new(timeout: @a0.conf.timeout, ignore: @ignore).until(&block)
      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

2 entries across 2 versions & 1 rubygems

Version Path
webdrone-1.18.2 lib/webdrone/wait.rb
webdrone-1.18.0 lib/webdrone/wait.rb