Sha256: 70c779a9f4203a98d22f441f79e51d92aeead1b3b9407eee71c2eeb18f9d0734

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Ferrum
  class Browser
    delegate %i[wait_for_css wait_for_csses wait_for_xpath wait_for_xpaths], to: :page
  end

  class Page
    delegate %i[wait_for_css wait_for_csses wait_for_xpath wait_for_xpaths], to: :main_frame
  end

  class Frame
    module DOM
      def wait_for_csses(selector, timeout: 3)
        wait_for_selector(selector, :css, timeout)
      end

      def wait_for_xpaths(selector, timeout: 3)
        wait_for_selector(selector, :xpath, timeout)
      end

      def wait_for_css(selector, timeout: 3)
        wait_for_selector(selector, :at_css, timeout)
      end

      def wait_for_xpath(selector, timeout: 3)
        wait_for_selector(selector, :at_xpath, timeout)
      end

      private

      def wait_for_selector(selector, selector_method, timeout)
        interval = 0.1
        (timeout / interval).to_i.times do
          nodes = send(selector_method, selector)
          return nodes if nodes
          sleep(interval)
        end
        nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fe_core_ext-0.33.0 lib/fe_core_ext/gem_ext/ferrum.rb