Sha256: ec6f29e8c48d46a0f6b38ee2a500853fc03a18bb7fc007d75df407945761f349

Contents?: true

Size: 1.29 KB

Versions: 47

Compression:

Stored size: 1.29 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

47 entries across 47 versions & 3 rubygems

Version Path
page-object-2.0.0 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-1.2.2 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-1.2.1 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-1.2.0 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-1.1.1 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page_object-1.1.3 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page_object-1.1.2 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page_object-1.1.1 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-1.1.0 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-1.0.3 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
meeane-page-object-0.1.11 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-1.0.2 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-1.0.1 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-1.0 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-0.9.8 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-0.9.7 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-0.9.6 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-0.9.5 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-0.9.4 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
page-object-0.9.3 lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb