From: aidy Date: 2006-08-14T23:10:12+09:00 Subject: case statement not being picked up Hi, This is my code and I have printed out some de-bug statements. I haven't a clue why the task = 'validate' switch statement is not being executed. class Form def initialize #see if file exists, what file or we going to use? #@filename = "search.txt" @filename = "validate.txt" end def enter_data task = nil count = 1 flag = 0 read_in_test_data.each { |x| line = x.chomp #debug p "line = #{x.chomp}" case line when /^\*+ TESTID_\d+$/ p line.gsub(/\*/, '') flag += 1 if flag > 1 $ie.back count = 1 end when /^Address:$/ task = :address when /^Country:$/ task = :country when /^Search-Results:$/ task = :search when /^Validate:$/ task = :validate when /^Expected-Result:$/ task = :verify when /^END:$/ $ie.close else p "the task = #{task}" case task when :address $ie.text_field(:name, "AL#{count}").set(line) count += 1 when :country $ie.text_field(:name, 'C1').set(line) when :validate $ie.button(:value, 'Validate').click when :search $ie.text_field(:name, 'NR1').set(line) $ie.button(:value, 'Search').click when :verify if $ie.contains_text(line) p line, "PASS" else p line, "FAIL" end else #whatever end end } end def read_in_test_data #check if file exists and give date of last change File.readlines(@filename, "\n" ) end private:read_in_test_data end debug statements "line = *********************************************** TESTID_100" " TESTID_100" "line = Address:" "line = Choyce Close" "the task = address" "line = Country:" "line = GB" "the task = country" "line = Validate:" "line = Expected-Result:" "line = Is Complete: " "the task = verify" the file being read *********************************************** TESTID_100 Address: Choyce Close Country: GB Validate: Expected-Result: Is Complete: false Confidence Level: 0 Address: Postal Authority Formatted Address: Choyce Close United Kingdom *********************************************** TESTID_200 etc Much appreciated Aidy