Sha256: 7ec448eaac4ed7c21d0302a626749fc50329a5181f7ce0c326b4c650257ecc5c

Contents?: true

Size: 728 Bytes

Versions: 2

Compression:

Stored size: 728 Bytes

Contents

module LocatorSpecHelper
  def driver
    @driver ||= mock(Selenium::WebDriver::Driver)
  end

  def locator(selector, attrs = Watir::HTMLElement.attributes)
    Watir::ElementLocator.new(driver, selector, attrs)
  end

  def expect_one(*args)
    driver.should_receive(:find_element).with(*args)
  end

  def expect_all(*args)
    driver.should_receive(:find_elements).with(*args)
  end

  def locate_one(*args)
    locator(*args).locate
  end

  def locate_all(*args)
    locator(*args).locate_all
  end

  def element(opts = {})
    attrs = opts.delete(:attributes)
    el = mock(Watir::Element, opts)

    attrs.each do |key, value|
      el.stub!(:attribute).with(key).and_return(value)
    end if attrs

    el
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watir-webdriver-0.0.9 spec/locator_spec_helper.rb
watir-webdriver-0.0.8 spec/locator_spec_helper.rb