Sha256: 393531264fb7c3238aca525b7351c6d48a21e8be9d151dd9d1f3317d90e5a094

Contents?: true

Size: 822 Bytes

Versions: 4

Compression:

Stored size: 822 Bytes

Contents

module Selenium

  # Link class that models the behavior of a link
  class Link < HtmlElement
    def Link::by_id(browser, id, target = nil)
      Link.new(WebPage.new(browser), "id=#{id}", target)
    end

    def Link::by_text(browser, text, target = nil)
      Link.new(WebPage.new(browser), "link=#{text}", target)
    end

    def initialize(webpage, locator, target = nil)
      super(webpage, locator)
      @target = target
    end

    def with_target(target)
      Link.new(webpage, locator, target.new(webpage.browser))
    end

    # click the link, wait for the page to load, and asserts the target that
    # was passed in during initialization
    def go
      raise "target page not defined for link #{@locator}" unless @target
      click_wait
      @target.ensure_present
      @target
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
jacobdam-selenium-1.1.16 lib/selenium/link.rb
Selenium-1.1.12 lib/selenium/link.rb
Selenium-1.1.11 lib/selenium/link.rb
Selenium-1.1.14 lib/selenium/link.rb