[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

show_links

DaFallus

6/9/2006 4:09:00 PM

Does anyone know of a way to store the output of show_links as an
array? I've tried setting the array equal to something like
ie.frame("mainFrame").show_links but the array always comes back as
nil.

I basically need this so I can loop through all the links on a page and
do various automated tests.

6 Answers

Chris Hulan

6/9/2006 5:22:00 PM

0

show_links grabs the links and sends them to stdout

it uses doc.links, so that may be what you need

cheers

Tim Hoolihan

6/9/2006 5:38:00 PM

0

If it uses the stdout, what about writing that part as a separate script
and using IO.popen, like:

links=[]
IO.popen("ie.rb") {|f| links.push f.gets}

ChrisH wrote:
> show_links grabs the links and sends them to stdout
>
> it uses doc.links, so that may be what you need
>
> cheers
>

pmr.nitrobackup

6/9/2006 6:31:00 PM

0


chris.defelice@gmail.com wrote:
> Does anyone know of a way to store the output of show_links as an
> array? I've tried setting the array equal to something like
> ie.frame("mainFrame").show_links but the array always comes back as
> nil.
>
> I basically need this so I can loop through all the links on a page and
> do various automated tests.

you need to do this:

ie.frame("mainFrame").links.each do |this_link|
# do something with this_link,
# eg puts this_link.to_s
# this_link.click
# etc
end

Paul

DaFallus

6/9/2006 7:01:00 PM

0


pmr.nitrobackup@gmail.com wrote:
> chris.defelice@gmail.com wrote:
> > Does anyone know of a way to store the output of show_links as an
> > array? I've tried setting the array equal to something like
> > ie.frame("mainFrame").show_links but the array always comes back as
> > nil.
> >
> > I basically need this so I can loop through all the links on a page and
> > do various automated tests.
>
> you need to do this:
>
> ie.frame("mainFrame").links.each do |this_link|
> # do something with this_link,
> # eg puts this_link.to_s
> # this_link.click
> # etc
> end
>
> Paul

Thanks! That helped a lot

pmr.nitrobackup

6/9/2006 7:40:00 PM

0


chris.defelice@gmail.com wrote:
> Does anyone know of a way to store the output of show_links as an
> array? I've tried setting the array equal to something like
> ie.frame("mainFrame").show_links but the array always comes back as
> nil.
>
> I basically need this so I can loop through all the links on a page and
> do various automated tests.

you need to do this:

ie.frame("mainFrame").links.each do |this_link|
# do something with this_link,
# eg puts this_link.to_s
# this_link.click
# etc
end

Paul

DaFallus

7/5/2006 5:09:00 PM

0

This is how I was able to fill an array with just the actual hyperlinks
of all the links on a page:

linkcount = Array.new
length = ie.document.frames.length

for i in 1..length
linkcount[i] = ie.frame(:index, i).links.length
for y in 1..linkcount[i]
ar[y] = ie.frame(:index, i).links[y].href
end
i = i + 1
end