Sha256: ae93e8b3e7054852c9ea4df274fcdc8d4316b3ba20c114551b910f4c97a6a433

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 KB

Contents

module PageObject
  module Platforms
    module SeleniumWebDriver
      class SurrogateSeleniumElement
        attr_accessor :identifier, :type, :tag, :other, :platform
        
        def exists?
          attempt_to_find_element unless @element
          @element ? (not @element.element.nil?) : false
        end
        
        def visible?
          attempt_to_find_element unless @element
          @element ? @element.element.displayed? : false
        end

        def nil?
          attempt_to_find_element unless @element
          @element ? @element.element.nil? : true
        end

        def displayed?
          attempt_to_find_element unless @element
          @element ? @element.element.displayed? : false
        end

        def method_missing(meth, *args)
          return @element.send(meth, *args) if @element
          $stderr.puts "You are calling #{meth} on an element that does not yet exist."
          raise Selenium::WebDriver::Error::NoSuchElementError
        end

        private

        def attempt_to_find_element
          @element = platform.send(:find_selenium_element, identifier, type, tag, other) unless @element
          @element = nil if @element.element.instance_of?(::PageObject::Platforms::SeleniumWebDriver::SurrogateSeleniumElement)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
page-object-lds-0.0.14 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-lds-0.0.13 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-lds-0.0.12 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-lds-0.0.11 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-lds-0.0.1 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
meeane-page-object-0.1.10 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
meeane-page-object-0.1.8 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb