I added this as a ticket - i hope i did it correctly.
anyway -  it is not brilliant, simply because now the root document is
a different animal to the frames.
I think is makes much more sence to address the root document as
ff.frame(:index, 0)
This results in a much more transparent logic for writing code - but
means that the firewatir frame code needs to conditionaly deal with it
- which is not very clean i.e.

if :index == 0 then set_browser_document

if might be better to cleanly distinguish more clearly between what
firefox is - and what it returns. i.e.

ff = Firefox.new #browser
document = ff.goto("some_url")

Then this would be possible and - i think more logical and
transparent.

#browser things can only do browser things i.e

document = ff.back
document = ff.forward
document = ff.goto

#document things and document things

document.frame(:index, 1).links
document.frame(:index, 2).links
document.links

or - but less obvious

document.frame(:index, 0).links #root document
document.frame(:index, 1).links
document.frame(:index, 2).links







On Apr 2, 11:20 pm, Charley Baker <[email protected]> wrote:
> Can you also add this as a jira ticket with this patch?
>
> Charley Baker
> blog:http://blog.charleybaker.org/
> Lead Developer, Watir,http://wtr.rubyforge.org
> QA Architect, Gap Inc Direct
>
> On Thu, Apr 2, 2009 at 1:11 PM, jason <[email protected]>wrote:
>
>
>
> > I descided to add the method get_frames and refactor show_frames in
> > the firefox.rb file as follows:
> > now i can call get_frames and recieve the frames in an array with
> > their attributes.
>
> > BTW if you do this you wont be able to get back to the root document
> > unless you also add the methods root to the firefox.rb file as well -
> > see below.
>
> >    def root
> >      set_browser_document
> >    end
>
> >    def get_frames
> >      jssh_request_frames
> >    end
>
> >    def show_frames
> >      frames = jssh_request_frames
>
> >      puts "There are #{frames.size} frames"
>
> >      frames.each_index do |index|
> >        puts "frame: name: #{frames[index].name}"
> >        puts "      index: #{index+1}"
> >      end
> >    end
> >    alias showFrames show_frames
>
> >    def jssh_request_frames
> >      jssh_command = "var frameset = #{WINDOW_VAR}.frames;
> >                            var elements_frames = new Array();
> >                            for(var i = 0; i < frameset.length; i++)
> >                            {
> >                                var frames = frameset[i].frames;
> >                                for(var j = 0; j < frames.length; j++)
> >                                {
> >                                    elements_frames.push(frames
> > [j].frameElement);
> >                                }
> >                            }
> >                            elements_frames.length;"
>
> >      jssh_command.gsub!("\n", "")
> >      $jssh_socket.send("#{jssh_command};\n", 0)
> >      length = read_socket().to_i
>
> >      frames = Array.new(length)
> >      for i in 0..length - 1 do
> >        frames[i] = Frame.new(self, :jssh_name, "elements_frames[#
> > {i}]")
> >      end
> >      frames
> >    end
>
> > On Apr 2, 5:32 pm, Paul Rogers <[email protected]> wrote:
> > > his doesnt answer your question, may be relevant;-)
> > > Some time back I was using firefox/firewatir to try and figure out if a
> > page
> > > had frames, and if it did how many etc. It proved surprisingly difficult,
> > I
> > > think because sometimes ( I cant remember what/how/why) firefox ( or
> > > firewatir ) would give me a chrome url, presumably this was something
> > like
> > > frame 0 or the main browser. I dont remember if this ever got resolved to
> > my
> > > satisfaction, or if I worked round it somehow.
>
> > > I would offer you my code, but firewatir has changed significantly since
> > I
> > > did this, and probably wont help you
>
> > > Paul
>
> > > On Thu, Apr 2, 2009 at 9:25 AM, jason <[email protected]
> > >wrote:
>
> > > > Thanks - I know this.....
>
> > > > The method is not helpful because it uses puts to output the frame
> > > > information.
> > > > The thing is - I don't need to see them - I want my program to
> > > > automatically review them. i.e. getting links and buttons etc.
>
> > > > On Apr 2, 5:19 pm, Wesley Chen <[email protected]> wrote:
> > > > > You may try:
> > > > > ff.show_frames
>
> > > > > Thanks.
> > > > > Wesley Chen.
>
> > > > > On Thu, Apr 2, 2009 at 10:44 PM, jason <
> > [email protected]
> > > > >wrote:
>
> > > > > > I have looked and looked through the docs and I simply cannot find
> > an
> > > > > > answer to this.
>
> > > > > > after calling
>
> > > > > > doc = firefox.goto("some_url")
>
> > > > > > I would like know what frames I have on the rendered page, i.e.
>
> > > > > > frames = doc.frames  #of cource this does not work, but I would
> > expect
> > > > > > an array of frame objects with their attributes returned.
>
> > > > > > how do I do this?
>
> > > > > > The only thing I found is doc.show_frames which is not exactly what
> > I
> > > > > > need.
>
> > > > > > Thanks for any help on this.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to