Watir: Getting frame name from index

D

DaFallus

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!
 
B

Bret Pettichord

DaFallus said:
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?
 
P

paul.rogers

DaFallus said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,048
Members
48,769
Latest member
Clifft

Latest Threads

Top