[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Watir: Getting frame name from index

DaFallus

6/12/2006 8:07:00 PM

After loading a page I first count how many frames are on the page.
Next I try to feed each frame index, or name if I could figure out how
to get that info, into an array. Later I plan on using this array to
loop through each frame while searching for some specific text.

print ie.show_frames
---------------------------------------------
frame index: 1 name: leftFrame
frame index: 2 name: topFrame
frame index: 3 name: mainFrame
---------------------------------------------

frameCount = ie.document.frames.length
ar = Array.new(frameCount)
counter = 1

while counter <= frameCount
ar[counter] = ie.frame(:index, counter)
counter = counter + 1
end

I am able to pull info about a specific frame by using ie.frame(:index,
1) but when using this in the loop above I receive the following error:
Unable to locate a frame with name #<Watir::Frame:0x2d0c818>

This is confusing to me since I am not specifying the name of the frame
but rather the index and I'm not sure why Watir is comparing the names.
I really just need a way to find out how to obtain the name of a frame
using its index.

As always I really appreciate any suggestions or ideas. Thanks!

2 Answers

bpettichord

6/12/2006 11:05:00 PM

0


DaFallus wrote:
> I am able to pull info about a specific frame by using ie.frame(:index,
> 1) but when using this in the loop above I receive the following error:
> Unable to locate a frame with name #<Watir::Frame:0x2d0c818>

Which line of your script is getting this error?

paul.rogers

6/13/2006 4:58:00 PM

0


DaFallus wrote:
> After loading a page I first count how many frames are on the page.
> Next I try to feed each frame index, or name if I could figure out how
> to get that info, into an array. Later I plan on using this array to
> loop through each frame while searching for some specific text.
>
> print ie.show_frames
> ---------------------------------------------
> frame index: 1 name: leftFrame
> frame index: 2 name: topFrame
> frame index: 3 name: mainFrame
> ---------------------------------------------
>
> frameCount = ie.document.frames.length
> ar = Array.new(frameCount)
> counter = 1
>
> while counter <= frameCount
> ar[counter] = ie.frame(:index, counter)
> counter = counter + 1
> end
>
> I am able to pull info about a specific frame by using ie.frame(:index,
> 1) but when using this in the loop above I receive the following error:
> Unable to locate a frame with name #<Watir::Frame:0x2d0c818>
>
> This is confusing to me since I am not specifying the name of the frame
> but rather the index and I'm not sure why Watir is comparing the names.
> I really just need a way to find out how to obtain the name of a frame
> using its index.
>
> As always I really appreciate any suggestions or ideas. Thanks!

Are you donig something like this later in the script:

ie.frame( ar[1] )

if so, thats already a watir::frame object

so you probably need

ar[1].button(xxxx).click

Paul