Sha256: 8569812a02aeaead5d203b9a6c05adb65b761fddc89662d7e8b354f37c79b4d9

Contents?: true

Size: 1.59 KB

Versions: 10

Compression:

Stored size: 1.59 KB

Contents

module Celerity
  module ClickableElement

    #
    # click the element
    #

    def click
      assert_exists_and_enabled
      rescue_status_code_exception { @container.update_page(@object.click) }
    end

    #
    # double click the element (Celerity only)
    #

    def double_click
      assert_exists_and_enabled
      rescue_status_code_exception { @container.update_page(@object.dblClick) }
    end

    #
    # right click the element (Celerity only)
    #

    def right_click
      assert_exists_and_enabled
      rescue_status_code_exception { @container.update_page(@object.rightClick) }
    end

    #
    # Click the element and return a new Browser instance with the resulting page.
    # This is useful for elements that trigger popups when clicked.
    #
    # @return [Celerity::Browser]
    #

    def click_and_attach
      assert_exists_and_enabled
      browser = Browser.new(@browser.options.dup)
      browser.webclient.set_cookie_manager(
        @browser.webclient.get_cookie_manager
      ) # hirobumi: we do want cookies as well.

      rescue_status_code_exception { browser.update_page(@object.click) }

      browser
    end

    #
    # Click the element and just return the content as IO. Current page stays unchanged.
    # This can be used to download content that normally isn't rendered in a browser.
    #
    # @return [IO]
    #

    def download
      assert_exists_and_enabled
      @object.click.getWebResponse.getContentAsStream.to_io
    end

    private

    def assert_exists_and_enabled
      assert_exists
      assert_enabled if respond_to?(:assert_enabled)
    end
  end
end

Version data entries

10 entries across 10 versions & 4 rubygems

Version Path
caius-celerity-0.0.6.10 lib/celerity/clickable_element.rb
caius-celerity-0.0.6.11 lib/celerity/clickable_element.rb
jarib-celerity-0.0.6.10 lib/celerity/clickable_element.rb
jarib-celerity-0.0.6.11 lib/celerity/clickable_element.rb
jarib-celerity-0.0.6.12 lib/celerity/clickable_element.rb
jarib-celerity-0.0.6.9 lib/celerity/clickable_element.rb
regularfry-celerity-0.0.6.12 lib/celerity/clickable_element.rb
walidhalabi-celerity-0.0.6.11 lib/celerity/clickable_element.rb
walidhalabi-celerity-0.0.6.12 lib/celerity/clickable_element.rb
walidhalabi-celerity-0.0.6.13 lib/celerity/clickable_element.rb