Sha256: 3950b7a6bef6dc7775dab368b468ce91699bcc4516797d0c7fa483e07d7a7b8a

Contents?: true

Size: 1.62 KB

Versions: 49

Compression:

Stored size: 1.62 KB

Contents

module Celerity
  module ClickableElement

    #
    # click the element
    #

    def click
      assert_exists_and_enabled
      rescue_status_code_exception { @object.click }
    end

    #
    # double click the element (Celerity only)
    #

    def double_click
      assert_exists_and_enabled
      rescue_status_code_exception { @object.dblClick }
    end

    #
    # right click the element (Celerity only)
    #

    def right_click
      assert_exists_and_enabled
      rescue_status_code_exception { @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.

      @browser.disable_event_listener do
        rescue_status_code_exception { browser.page = @object.click }
      end

      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
      @browser.disable_event_listener do
        @object.click.getWebResponse.getContentAsStream.to_io
      end
    end

    private

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

Version data entries

49 entries across 49 versions & 7 rubygems

Version Path
drnic-celerity-0.0.6.17 lib/celerity/clickable_element.rb
jarib-celerity-0.0.6.14 lib/celerity/clickable_element.rb
jarib-celerity-0.0.6.15 lib/celerity/clickable_element.rb
jarib-celerity-0.0.6.16 lib/celerity/clickable_element.rb
jarib-celerity-0.0.6.17 lib/celerity/clickable_element.rb
jarib-celerity-0.0.6.18 lib/celerity/clickable_element.rb
jarib-celerity-0.0.6.19 lib/celerity/clickable_element.rb
jarib-celerity-0.0.7.1 lib/celerity/clickable_element.rb
celerity_thingista-0.9.3 lib/celerity/clickable_element.rb
celerity_thingista-0.9.2 lib/celerity/clickable_element.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/celerity-0.9.2/lib/celerity/clickable_element.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/celerity-0.9.2/lib/celerity/clickable_element.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/celerity-0.9.2/lib/celerity/clickable_element.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/celerity-0.9.2/lib/celerity/clickable_element.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/celerity-0.9.2/lib/celerity/clickable_element.rb
celerity-0.9.2 lib/celerity/clickable_element.rb
celerity-0.9.1 lib/celerity/clickable_element.rb
celerity-0.9.0 lib/celerity/clickable_element.rb
celerity-0.8.9 lib/celerity/clickable_element.rb
celerity-0.8.9.pre lib/celerity/clickable_element.rb