Sha256: 4758faea650a1332e77fe145c0c107895e2b9f35cb57299e1f5a855cef433c6f

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

# encoding: utf-8
require File.expand_path('spec_helper', File.dirname(__FILE__))

describe "TableCells" do

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

  #  describe "#length" do
  #    it "returns the number of cells" do
  #      browser.table(:id, 'outer').cells.length.should == 6
  #      browser.table(:id, 'inner').cells.length.should == 2
  #    end
  #  end
  #
  #  describe "#[]" do
  #    it "returns the row at the given index" do
  #      browser.table(:id, 'outer').cells[0].text.should == "Table 1, Row 1, Cell 1"
  #      browser.table(:id, 'inner').cells[0].text.should == "Table 2, Row 1, Cell 1"
  #      browser.table(:id, 'outer').cells[6].text.should == "Table 1, Row 3, Cell 2"
  #    end
  #  end

  describe "#each" do
    it "iterates through cells correctly" do
      # All cells on the page
      count = 0

      browser.cells.each_with_index do |c, index|
        c.id.should == browser.cell(:index, index).id
        c.value.should == browser.cell(:index, index).value

        count += 1
      end

      count.should > 0

      # Cells inside a table
      count = 0

      inner_table = browser.table(:id, 'inner')
      inner_table.cells.each_with_index do |c, index|
        c.id.should == inner_table.cell(:index, index).id
        c.value.should == inner_table.cell(:index, index).value

        count += 1
      end

      count.should > 0

      # Cells inside a table (should not include cells inside a table inside a table)
      outer_table = browser.table(:id, 'outer')
      count = 0

      outer_table.cells.each_with_index do |c, index|
        c.id.should == outer_table.cell(:index, index).id
        c.value.should == outer_table.cell(:index, index).value

        count += 1
      end

      count.should > 0
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watir-webdriver-0.0.9 spec/watirspec/table_cells_spec.rb
watir-webdriver-0.0.8 spec/watirspec/table_cells_spec.rb