Sha256: 3c0b1796609f9fd0ecab453165477fedd82ad6d446135ca7adbb6430ab2f4801

Contents?: true

Size: 902 Bytes

Versions: 3

Compression:

Stored size: 902 Bytes

Contents

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

  class Text
    attr_accessor :a0

    def initialize(a0)
      @a0 = a0
    end

    def text(text, n: 1, all: false, visible: true)
      item = @a0.find.send __callee__, text, n: n, all: all, visible: visible
      if item.is_a? Array
        item.collect(&:text)
      else
        item.text
      end
    rescue => exception
      Webdrone.report_error(@a0, exception, Kernel.caller_locations)
    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 => exception
      Webdrone.report_error(@a0, exception, Kernel.caller_locations)
    end

    protected :text
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
webdrone-1.0.4 lib/webdrone/text.rb
webdrone-1.0.0 lib/webdrone/text.rb
webdrone-0.9.9 lib/webdrone/text.rb