From: "Jesús Gabriel y Galán" Date: 2010-05-12T01:48:34+09:00 Subject: Re: How to read data in text file and put into the web page On Tue, May 11, 2010 at 6:38 PM, Zubair Ansari wrote: > Hi i want to read data in the text file like. > > > username=abcd > password=1234 > > i write code through the counter and i want write code without counter. > Plz help me...................... You have a file with just those two variables? Then you can do this: contents = File.read("c:/test/test.txt") data = contents.map do |line| line.chomp.split("=")[1] end Then you have data[0] #=> abcd data[1] #=> 1234 and you can use those directly: ie.text_field(:name,"userId").set(data[0]) ie.text_field(:name,"password").set(data[1]) Hope this helps, Jesus. > > require 'watir' > include Watir > > counter = 1 > > ie=Watir::IE.start("http://www.google.co.in") > file = File.new("c:/test/test.txt", "r") > > while (line =  file.gets '=') >     line = file.readline >                 while(counter == 1) >                        ie.text_field(:name,"userId").set(line) >                   break >               end >               while(counter == 2) >                         ie.text_field(:name,"password").set(line) >                   break >               end >              counter = counter + 1 > end > file.close > ie.button(:name,"Submit").click() > -- > Posted via http://www.ruby-forum.com/. > >