Sha256: f6b6e203a693d75b2b3df2cbbe96248af544a1c43c4600bcc490dfb23ccb8693

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require 'watirspec_helper'

module Watir
  describe List do
    before do
      browser.goto(WatirSpec.url_for('non_control_elements.html'))
    end

    it 'returns the list items assocaited with an Ol' do
      items = browser.ol(id: 'favorite_compounds').list_items
      expect(items).to be_a Watir::LICollection
      expect(items).to all(be_a Watir::LI)
    end

    it 'returns the list items assocaited with an Ul' do
      items = browser.ul(id: 'navbar').list_items
      expect(items).to be_a Watir::LICollection
      expect(items).to all(be_a Watir::LI)
    end

    it 'gets the size of a list' do
      ul = browser.ul(id: 'navbar')
      expect(ul.size).to eq 7
    end

    it 'iterates over a list' do
      ul = browser.ul(id: 'navbar')
      expect(ul.map(&:tag_name)).to eq Array.new(7, 'li')
    end

    it 'gets a list item at the specified index' do
      ul = browser.ul(id: 'navbar')
      expect(ul[4].text).to eq 'Non-link 1'
    end

    it 'returns the list item size' do
      items = browser.ol(id: 'favorite_compounds').list_items
      expect(items.size).to eq 5
    end

    it 'returns list item at an index' do
      items = browser.ol(id: 'favorite_compounds').list_items
      third = browser.ol(id: 'favorite_compounds').li(index: 2)

      expect(items[2]).to eq third
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
watir-7.3.0 spec/watirspec/elements/list_spec.rb
watir-7.2.2 spec/watirspec/elements/list_spec.rb
watir-7.2.1 spec/watirspec/elements/list_spec.rb