Sha256: a94a3370392c76e0edc50e239985c188db03b9582636ec6c0b3692b3f13e9d40

Contents?: true

Size: 1.28 KB

Versions: 13

Compression:

Stored size: 1.28 KB

Contents

require 'watirspec_helper'

describe 'Divs' do
  before :each do
    browser.goto(WatirSpec.url_for('non_control_elements.html'))
  end

  describe 'with selectors' do
    it 'returns the matching elements' do
      expect(browser.divs(id: 'header').to_a).to eq [browser.div(id: 'header')]
    end
  end

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

  describe '#[]' do
    it 'returns the div at the given index' do
      expect(browser.divs[1].id).to eq 'outer_container'
    end

    it 'returns an array of divs with a given range of positive values' do
      divs = browser.divs[2..4]
      ids = divs.map(&:id)
      expect(ids).to eq %w[header promo content]
    end

    it 'returns an array of divs with a given range including negative values' do
      divs = browser.divs[11..-3]
      ids = divs.map(&:id)
      expect(ids).to eq %w[messages ins_tag_test del_tag_test]
    end
  end

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

      browser.divs.each_with_index do |d, index|
        expect(d.id).to eq browser.div(index: index).id
        expect(d.class_name).to eq browser.div(index: index).class_name

        count += 1
      end

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
watir-6.19.1 spec/watirspec/elements/divs_spec.rb
watir-6.19.0 spec/watirspec/elements/divs_spec.rb
watir-6.18.0 spec/watirspec/elements/divs_spec.rb
watir-6.17.0 spec/watirspec/elements/divs_spec.rb
watir-6.16.5 spec/watirspec/elements/divs_spec.rb
watir-6.16.4 spec/watirspec/elements/divs_spec.rb
watir-6.16.3 spec/watirspec/elements/divs_spec.rb
watir-6.16.2 spec/watirspec/elements/divs_spec.rb
watir-6.16.1 spec/watirspec/elements/divs_spec.rb
watir-6.16.0 spec/watirspec/elements/divs_spec.rb
watir-6.15.1 spec/watirspec/elements/divs_spec.rb
watir-6.15.0 spec/watirspec/elements/divs_spec.rb
watir-6.14.0 spec/watirspec/elements/divs_spec.rb