路漫漫其修远兮,吾将上下而求索

针对Table and CheckBox的watir脚本

上一篇 / 下一篇  2009-10-15 16:06:37 / 个人分类:Ruby_Watir

require 'watir'
require 'win32ole'
require 'watir/WindowHelper'
require 'test/unit'

class CheckBox < Test::Unit::TestCase
  def test_Checkbox
    
    ie_site="http://members.shaw.ca/paul_rogers/watir_tests/checkboxes1.html"
    ie=Watir::IE.new
    ie.goto ie_site
    
    ie.show_tables
    
    my_table=ie.table(:index,1)
    my_table.each {|row| p row.to_s}
    
    if ie.checkboxes[1].checked?
      puts "Failed"
      else
        puts "The checkbox1 is not checked in default"
      end
    
    #assert(ie.checkboxes[1].checked,"Test Failed")
    
    for i in 0..1
    ie.checkboxes[1].click
    if ie.checkboxes[1].checked?
      puts "The Checkbox 1 is checked"
      else
        puts "The Checkbox 1 is not checked"
      end
    end
    
    puts "===================================="
    
    if ie.checkboxes[2].disabled==true
      puts "Disabled's checkbox can not be used"
      else
        puts "Disabled's checkbox should not be used"
      end
      
      assert(ie.checkboxes[2].disabled==true,"Test Failed")
      
      puts "===================================="
      
      for i in 0..1
      if ie.checkboxes[3].checked?
        puts "The set checkbox is checked"
        ie.checkboxes[3].click
        puts "#{my_table[3][0].text}"
        else
          puts "Clicked the set checkboxes"
        end
      end
      
      assert(ie.checkboxes[3].disabled==false,"Checkbox 3 is not disabled,Test Failed")
      
      puts "===================================="
      
      my_table[4][0].text
      for i in 4..7
      if ie.checkboxes[i].checked?
        puts "The checkbox #{i} is checked in default"
        else
          puts "The checkbox #{i} is not checked in default"
        end
        assert(ie.checkboxes[i].value=="#{i-3}","Checkbox #{i}'s values do not equal to #{i-3}Test Failed")
      end
      
      assert(ie.checkboxes[8].disabled==true,"Checkbox 8 is not disable,Test Failed")
      
      puts "===================================="
      
      my_table[5].text
      assert(ie.button(:name,"foo").disabled==true,"Button foo is not disabled ,so Test Failed")
      ie.close
      
    end
  end
  

TAG:

 

评分:0

我来说两句

我的栏目

日历

« 2024-05-11  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 40450
  • 日志数: 76
  • 图片数: 2
  • 建立时间: 2007-11-02
  • 更新时间: 2011-08-13

RSS订阅

Open Toolbar