Sha256: dfc081b5fbda7005c1c455615c07794df33e01d98ff07b49d588f387c6ca86a1

Contents?: true

Size: 960 Bytes

Versions: 6

Compression:

Stored size: 960 Bytes

Contents

# frozen_string_literal: true

module Webdrone
  class Browser
    def text
      @text ||= Text.new self
    end
  end

  class Text
    attr_reader :a0

    def initialize(a0)
      @a0 = a0
    end

    def text(text, n: 1, all: false, visible: true, scroll: false, parent: a0.conf.parent)
      item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, scroll: scroll, parent: parent
      if item.is_a? Array
        item.collect(&:text)
      else
        item.text
      end
    rescue StandardError => error
      Webdrone.report_error(@a0, error)
    end

    alias_method :id,     :text
    alias_method :css,    :text
    alias_method :link,   :text
    alias_method :button, :text
    alias_method :on,     :text
    alias_method :option, :text
    alias_method :xpath,  :text

    def page_title
      @a0.driver.title
    rescue StandardError => error
      Webdrone.report_error(@a0, error)
    end

    protected :text
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
webdrone-1.18.2 lib/webdrone/text.rb
webdrone-1.18.0 lib/webdrone/text.rb
webdrone-1.16.2 lib/webdrone/text.rb
webdrone-1.16.0 lib/webdrone/text.rb
webdrone-1.14.0 lib/webdrone/text.rb
webdrone-1.12.0 lib/webdrone/text.rb