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 <paul.rog...@shaw.ca> 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 <jason.franklin.sto...@gmail.com>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 <cjq....@gmail.com> wrote:
> > > You may try:
> > > ff.show_frames
>
> > > Thanks.
> > > Wesley Chen.
>
> > > On Thu, Apr 2, 2009 at 10:44 PM, jason <jason.franklin.sto...@gmail.com
> > >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 watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to