Sha256: 7a6a8ddc90a409871541721f0b1b8cb6925f42dc70c18195aedd2a11f9c737f2

Contents?: true

Size: 1.36 KB

Versions: 6

Compression:

Stored size: 1.36 KB

Contents

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
require 'unittests/setup'


class TC_TestElementCollectionIndexingForOneBasedIndexes < Test::Unit::TestCase

  def setup
    close_browser
    Watir.options[:zero_based_indexing] = false
    goto_page "zeroindex.html"    
  end

  def teardown
    Watir.options[:zero_based_indexing] = true
    close_browser
  end

  def test_one_based_index    
    assert browser.table(:id, 'a_table').rows.length == 6

    #row 1
    r = browser.table(:id, 'a_table').rows[1]
    assert r.id == 'first'

    #something in the middle
    r = browser.table(:id, 'a_table').rows[2]
    assert r.id == 'second'

    #the last row
    r = browser.table(:id, 'a_table').rows[6]
    assert r.id == 'sixth'
  end
end

class TC_TestElementCollectionIndexingForZeroBasedIndexes < Test::Unit::TestCase

  def setup
    #currently the watir default is zero based index    
    goto_page "zeroindex.html"
  end

  def test_zero_based_index
    assert browser.table(:id, 'a_table').rows.length == 6

    #row 1
    r = browser.table(:id, 'a_table').rows[0]
    assert r.id == 'first'

    #something in the middle
    r = browser.table(:id, 'a_table').rows[2]
    assert r.id == 'third'

    #last row
    r = browser.table(:id, 'a_table').rows[5]
    assert r.id == 'sixth'
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
watir-classic-3.0.0 unittests/element_collection_indexes_test.rb
watir-3.0.0.rc3 unittests/element_collection_indexes_test.rb
watir-3.0.0.rc2 unittests/element_collection_indexes_test.rb
watir-3.0.0.rc1 unittests/element_collection_indexes_test.rb
watir-2.0.4 unittests/element_collection_indexes_test.rb
watir-2.0.3 unittests/element_collection_indexes_test.rb