Sha256: db9ddf2d77a139e7cd47c834d0f76bdc62ed0798ef98102a4fe4fe1144574860

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

# encoding: utf-8
require File.expand_path("../spec_helper", __FILE__)

describe "Buttons" do

  before :each do
    browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
  end

  bug "http://github.com/jarib/celerity/issues#issue/25", :celerity do
    describe "with selectors" do
      it "returns the matching elements" do
        browser.buttons(:name => "new_user_button").to_a.should == [browser.button(:name => "new_user_button")]
      end
    end
  end
  
  describe "#length" do
    it "returns the number of buttons" do
      browser.buttons.length.should == 8
    end
  end

  describe "#[]" do
    it "returns the button at the given index" do
      browser.buttons[0].title.should == "Submit the form"
    end
  end

  describe "#first" do
    it "returns the first element in the collection" do
      browser.buttons.first.value.should == browser.buttons[0].value
    end
  end

  describe "#last" do
    it "returns the last element in the collection" do
      browser.buttons.last.value.should == browser.buttons[-1].value
    end
  end

  describe "#each" do
    it "iterates through buttons correctly" do
      count = 0

      browser.buttons.each_with_index do |b, index|
        b.name.should == browser.button(:index, index).name
        b.id.should == browser.button(:index, index).id
        b.value.should == browser.button(:index, index).value

        count += 1
      end

      count.should > 0
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
watir-webdriver-0.1.4 spec/watirspec/buttons_spec.rb
watir-webdriver-0.1.3 spec/watirspec/buttons_spec.rb
watir-webdriver-0.1.2 spec/watirspec/buttons_spec.rb