Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > select_list WATIR codes..

Reply
Thread Tools

select_list WATIR codes..

 
 
curious
Guest
Posts: n/a
 
      11-09-2006
I have something funny going on with my WATIR. code.

in the code below, test.txt file has about 50 lines.. for example, line
number 1 is 'test1', number 2 is 'test2', and so on..

I am trying to choose this line value in the select box in the web page
one by one from the local text file and process it.

in the below code, the line..

ie.select_list( :name , "leftsegments").select("#{$Guide}")

is supposed to choose test1 from the select box, which is the first
line in the test.txt file. Now even though test1 is one of the values
in the select box, the message says 'there is no 'text1' in the select
list.

so I tried the code below again with

ie.select_list( :name , "leftsegments").select("test1")

and it works fine..

what am I doing wrong?? the select box in the web page has more than
150 values.. maybe too many values to choose from?? is that confusing
the WATIR code?? but what about the error message that says 'there is
no test1 in the select list'????

could anyone help and tell me what I am doing wrong??

thanks.

================================================== ======================
require 'watir'

ie = Watir::IE.start("http://www.testing.com")
ie.link(:text, "New Page").click
file = File.open("c:/test.txt", "r")
lines = file.readlines()
0.upto(lines.length - 1) {|j|
$Guide = lines[j]
ie.button(:name, "choose_segments").click
ie.select_list( :name , "leftsegments").select("#{$Guide}")
ie.button(:name, "leftsegmentsButton").click
}
file.close()
lines.clear()

 
Reply With Quote
 
 
 
 
curious
Guest
Posts: n/a
 
      11-09-2006
<select name=leftsegments multiple size=8>

one more comment.. above is the select HTML on the web page.. does
multiple size being 8 would have anything to do with the problem I am
having??

So I changed the first line in the text file to the first one in the
select list.. but still the same situation..

any help will be deeply appreciated..

thanks.

curious wrote:
> I have something funny going on with my WATIR. code.
>
> in the code below, test.txt file has about 50 lines.. for example, line
> number 1 is 'test1', number 2 is 'test2', and so on..
>
> I am trying to choose this line value in the select box in the web page
> one by one from the local text file and process it.
>
> in the below code, the line..
>
> ie.select_list( :name , "leftsegments").select("#{$Guide}")
>
> is supposed to choose test1 from the select box, which is the first
> line in the test.txt file. Now even though test1 is one of the values
> in the select box, the message says 'there is no 'text1' in the select
> list.
>
> so I tried the code below again with
>
> ie.select_list( :name , "leftsegments").select("test1")
>
> and it works fine..
>
> what am I doing wrong?? the select box in the web page has more than
> 150 values.. maybe too many values to choose from?? is that confusing
> the WATIR code?? but what about the error message that says 'there is
> no test1 in the select list'????
>
> could anyone help and tell me what I am doing wrong??
>
> thanks.
>
> ================================================== ======================
> require 'watir'
>
> ie = Watir::IE.start("http://www.testing.com")
> ie.link(:text, "New Page").click
> file = File.open("c:/test.txt", "r")
> lines = file.readlines()
> 0.upto(lines.length - 1) {|j|
> $Guide = lines[j]
> ie.button(:name, "choose_segments").click
> ie.select_list( :name , "leftsegments").select("#{$Guide}")
> ie.button(:name, "leftsegmentsButton").click
> }
> file.close()
> lines.clear()


 
Reply With Quote
 
 
 
 
curious
Guest
Posts: n/a
 
      11-09-2006
I did some addtional testing, and i think the problem has something to
do with the format of the line read by the code..

I tried other select boxes that surely worked fine.. but once i read
the choices in the select box from the local text file, then the same
problem persists.

could anyone please tell me how I should adjust the format of each line
read from the local text file so that the WATIR code select each option
one by one from the text file??

thanks.

curious wrote:
> <select name=leftsegments multiple size=8>
>
> one more comment.. above is the select HTML on the web page.. does
> multiple size being 8 would have anything to do with the problem I am
> having??
>
> So I changed the first line in the text file to the first one in the
> select list.. but still the same situation..
>
> any help will be deeply appreciated..
>
> thanks.
>
> curious wrote:
> > I have something funny going on with my WATIR. code.
> >
> > in the code below, test.txt file has about 50 lines.. for example, line
> > number 1 is 'test1', number 2 is 'test2', and so on..
> >
> > I am trying to choose this line value in the select box in the web page
> > one by one from the local text file and process it.
> >
> > in the below code, the line..
> >
> > ie.select_list( :name , "leftsegments").select("#{$Guide}")
> >
> > is supposed to choose test1 from the select box, which is the first
> > line in the test.txt file. Now even though test1 is one of the values
> > in the select box, the message says 'there is no 'text1' in the select
> > list.
> >
> > so I tried the code below again with
> >
> > ie.select_list( :name , "leftsegments").select("test1")
> >
> > and it works fine..
> >
> > what am I doing wrong?? the select box in the web page has more than
> > 150 values.. maybe too many values to choose from?? is that confusing
> > the WATIR code?? but what about the error message that says 'there is
> > no test1 in the select list'????
> >
> > could anyone help and tell me what I am doing wrong??
> >
> > thanks.
> >
> > ================================================== ======================
> > require 'watir'
> >
> > ie = Watir::IE.start("http://www.testing.com")
> > ie.link(:text, "New Page").click
> > file = File.open("c:/test.txt", "r")
> > lines = file.readlines()
> > 0.upto(lines.length - 1) {|j|
> > $Guide = lines[j]
> > ie.button(:name, "choose_segments").click
> > ie.select_list( :name , "leftsegments").select("#{$Guide}")
> > ie.button(:name, "leftsegmentsButton").click
> > }
> > file.close()
> > lines.clear()


 
Reply With Quote
 
Patrick Spence
Guest
Posts: n/a
 
      11-09-2006

curious wrote:
> > could anyone help and tell me what I am doing wrong??
> > ie.select_list( :name , "leftsegments").select({$Guide}")


I suspect the trailing newline character; "\n", is what's eating your
lunch on this. Here's what I cobbled-up and it works just fine...

file = File.open("test.txt", "r+")
lines = file.readlines()

lines.each {|testName|
ie.select_list(:name, "leftsegments").select(testName.chop!) #--
notice use of .chop!
sleep(0.25)
}

file.close()
lines.clear()


 
Reply With Quote
 
Patrick Spence
Guest
Posts: n/a
 
      11-09-2006

curious wrote:
> > could anyone help and tell me what I am doing wrong??
> > ie.select_list( :name , "leftsegments").select({$Guide}")


I suspect the trailing newline character; "\n", is what's eating your
lunch on this. Here's what I cobbled-up and it works just fine...

file = File.open("test.txt", "r+")
lines = file.readlines()

lines.each {|testName|
ie.select_list(:name, "leftsegments").select(testName.chop!) #--
notice use of .chop!
sleep(0.25)
}

file.close()
lines.clear()


 
Reply With Quote
 
Chris McMahon
Guest
Posts: n/a
 
      11-09-2006

chomp:
http://www.rubycentral.com/book/ref_...l#String.chomp

curious wrote:
> I did some addtional testing, and i think the problem has something to
> do with the format of the line read by the code..
>
> I tried other select boxes that surely worked fine.. but once i read
> the choices in the select box from the local text file, then the same
> problem persists.
>
> could anyone please tell me how I should adjust the format of each line
> read from the local text file so that the WATIR code select each option
> one by one from the text file??
>
> thanks.
>
> curious wrote:
> > <select name=leftsegments multiple size=8>
> >
> > one more comment.. above is the select HTML on the web page.. does
> > multiple size being 8 would have anything to do with the problem I am
> > having??
> >
> > So I changed the first line in the text file to the first one in the
> > select list.. but still the same situation..
> >
> > any help will be deeply appreciated..
> >
> > thanks.
> >
> > curious wrote:
> > > I have something funny going on with my WATIR. code.
> > >
> > > in the code below, test.txt file has about 50 lines.. for example, line
> > > number 1 is 'test1', number 2 is 'test2', and so on..
> > >
> > > I am trying to choose this line value in the select box in the web page
> > > one by one from the local text file and process it.
> > >
> > > in the below code, the line..
> > >
> > > ie.select_list( :name , "leftsegments").select("#{$Guide}")
> > >
> > > is supposed to choose test1 from the select box, which is the first
> > > line in the test.txt file. Now even though test1 is one of the values
> > > in the select box, the message says 'there is no 'text1' in the select
> > > list.
> > >
> > > so I tried the code below again with
> > >
> > > ie.select_list( :name , "leftsegments").select("test1")
> > >
> > > and it works fine..
> > >
> > > what am I doing wrong?? the select box in the web page has more than
> > > 150 values.. maybe too many values to choose from?? is that confusing
> > > the WATIR code?? but what about the error message that says 'there is
> > > no test1 in the select list'????
> > >
> > > could anyone help and tell me what I am doing wrong??
> > >
> > > thanks.
> > >
> > > ================================================== ======================
> > > require 'watir'
> > >
> > > ie = Watir::IE.start("http://www.testing.com")
> > > ie.link(:text, "New Page").click
> > > file = File.open("c:/test.txt", "r")
> > > lines = file.readlines()
> > > 0.upto(lines.length - 1) {|j|
> > > $Guide = lines[j]
> > > ie.button(:name, "choose_segments").click
> > > ie.select_list( :name , "leftsegments").select("#{$Guide}")
> > > ie.button(:name, "leftsegmentsButton").click
> > > }
> > > file.close()
> > > lines.clear()


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Watir: How to return a Watir::IE object for an existing IE? Anukul Singhal Ruby 1 05-15-2008 04:57 PM
How to click on the select_list little drop down arrow Vikash Kumar Ruby 0 11-29-2006 07:38 AM
watir and iframes? armin@approximity.com Ruby 3 07-08-2005 02:42 PM
Watir, XML, Espen Falkevik Ruby 3 06-17-2005 02:04 PM
Watir needs a Win32GUI library Bret Pettichord Ruby 0 03-12-2005 03:24 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57