Sha256: df1f7524aedaa84ca97cb86c42e91d7cbe12d16090672f1bf0710667c3b5c1ab

Contents?: true

Size: 880 Bytes

Versions: 16

Compression:

Stored size: 880 Bytes

Contents

require 'watirspec_helper'

describe 'Labels' do
  before :each do
    browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
  end

  describe 'with selectors' do
    it 'returns the matching elements' do
      expect(browser.labels(for: 'new_user_first_name').to_a).to eq [browser.label(for: 'new_user_first_name')]
    end
  end

  describe '#length' do
    it 'returns the number of labels' do
      expect(browser.labels.length).to eq 45
    end
  end

  describe '#[]' do
    it 'returns the label at the given index' do
      expect(browser.labels[0].id).to eq 'first_label'
    end
  end

  describe '#each' do
    it 'iterates through labels correctly' do
      count = 0

      browser.labels.each_with_index do |l, index|
        expect(l.id).to eq browser.label(index: index).id
        count += 1
      end

      expect(count).to be > 0
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
watir-7.1.0 spec/watirspec/elements/labels_spec.rb
watir-7.0.0 spec/watirspec/elements/labels_spec.rb
watir-7.0.0.beta5 spec/watirspec/elements/labels_spec.rb
watir-7.0.0.beta4 spec/watirspec/elements/labels_spec.rb
watir-7.0.0.beta3 spec/watirspec/elements/labels_spec.rb
watir-7.0.0.beta2 spec/watirspec/elements/labels_spec.rb
watir-7.0.0.beta1 spec/watirspec/elements/labels_spec.rb
watir-6.19.1 spec/watirspec/elements/labels_spec.rb
watir-6.19.0 spec/watirspec/elements/labels_spec.rb
watir-6.18.0 spec/watirspec/elements/labels_spec.rb
watir-6.17.0 spec/watirspec/elements/labels_spec.rb
watir-6.16.5 spec/watirspec/elements/labels_spec.rb
watir-6.16.4 spec/watirspec/elements/labels_spec.rb
watir-6.16.3 spec/watirspec/elements/labels_spec.rb
watir-6.16.2 spec/watirspec/elements/labels_spec.rb
watir-6.16.1 spec/watirspec/elements/labels_spec.rb