<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">interesting - I get an "unknown frame exception" instead of an "unknown object exception" using locate.<div><br></div><div><div>>> browser.frame("main").locate()</div><div>Watir::Exception::UnknownFrameException: Unable to locate a frame using name and main. </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.5/lib/firewatir/elements/frame.rb:29:in `locate'</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>from (irb):66</div><div><br></div><div><div>>> browser.frame("main").locate_frame(:name, 'main')</div><div>Watir::Exception::UnknownObjectException: Unable to locate element, using :name, "main"</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.5/lib/firewatir/element.rb:907:in `assert_exists'</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.5/lib/firewatir/element.rb:1266:in `method_missing'</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>from (irb):64</div><div><br></div><div>How would I open the frame directly?</div><div>The frame I want has an ID, even this doesn't help.</div><div><br></div><div>An Xpath search fails:</div><div><div>>> browser.element_by_xpath('//*[@id="main_ID"]')</div><div>=> #<FireWatir::Link:0x1a7fdcc located=false how=:jssh_name what=nil></div><div><br></div></div><div><br></div></div><div><div>On 20-Apr-10, at 12:35 PM, Sean Walberg wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">If you RTSL a bit you'll see that calling browser.frame creates a new element but doesn't validate it actually found anything. When you call the html method it first asserts that the object exists and throws an exception if not.<div> <br></div><div>The located=false comes from the element#inspect method, (which just taught me a new Ruby idiom: !!@o returns true if @o is a valid object or false if it isn't.) So located=false means that the object never existed, nor will it ever.</div> <div><br></div><div>While poking around I saw a locate_frame method. Maybe that might work better? (It's actually possible that .frame uses locate_frame, I didn't trace it far enough)</div><div><br></div><div>Failing that, what about opening the frame directly?</div> <div><br></div><div>Sean</div><div><br></div><div><br><br><div class="gmail_quote">On Tue, Apr 20, 2010 at 12:05 PM, Dan Martin <span dir="ltr"><<a href="mailto:ummar143@shaw.ca">ummar143@shaw.ca</a>></span> wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word">As noted in the previous email<div><div class="im"><div>>> browser.frame("main")</div> <div>=> #<FireWatir::Frame:0x1a90dd4 located=false how=:name what="main"></div><div><br></div></div><div>"located=false" seems to be Firewatir's way of saying that the object doesn't exist until I ask for it.</div> <div>If I try to use it anyway, I get an unknown object exception</div><div><br></div><div><div>>> browser.frame("main").html</div><div>Watir::Exception::UnknownObjectException: Unable to locate element, using :name, "main"</div> <div><span style="white-space:pre">        </span>from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.5/lib/firewatir/element.rb:907:in `assert_exists'</div><div><span style="white-space:pre">        </span>from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.5/lib/firewatir/elements/frame.rb:34:in `html'</div> <div><span style="white-space:pre">        </span>from (irb):62</div><div><br></div></div><div><div></div><div class="h5"><div><div>On 20-Apr-10, at 11:34 AM, Sean Walberg wrote:</div><br><blockquote type="cite"><div><br></div>Looking at the rdocs, <a href="http://wtr.rubyforge.org/rdoc/1.6.5/" target="_blank">http://wtr.rubyforge.org/rdoc/1.6.5/</a>, have you tried<div> <br></div><div>browser.frame("main").html</div><div><br></div><div> ?<br><br><div class="gmail_quote">On Tue, Apr 20, 2010 at 10:51 AM, Dan Martin <span dir="ltr"><<a href="mailto:ummar143@shaw.ca" target="_blank">ummar143@shaw.ca</a>></span> wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> I am learning to navigate and scrape. I have had more success with<br> Firewatir than Ruby mechanize, but both are poorly documented.<br> <br> Current problem: logging into a site webpage, Firwatir can see the<br> frames, but cannot access them.<br> <br> >> browser.show_frames<br> There are 3 frames<br> frame: name: topbar<br> index: 1<br> frame: name: langFrame<br> index: 2<br> frame: name: main<br> index: 3<br> => 0..2<br> <br> >> browser.frame(:index, 1)<br> => #<FireWatir::Frame:0x1a9260c located=false how=:index what=1><br> <br> >> browser.frame("main")<br> => #<FireWatir::Frame:0x1a90dd4 located=false how=:name what="main"><br> <br> Firefox shows the webpage source [I show only the top levels]<br> structure as:<br> <br> <html><br> <br> <head><br> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"><br> <title>TITLE</title><br> <link rel="stylesheet" href="all.css"><br> <br> <script language="JavaScript" src="WEBPAGE"></script><br> <script language="JavaScript">FUNCTIONS</script><br> </head><br> <br> <frameset rows="63,0,*" border="0" id="frameset_ID" framespacing="0"<br> frameborder="no" onload="loadHomepage(1);" onunload="forceLogout();"><br> <frame src="/TDM/header.htm" name="topbar" scrolling="no"<br> noresize>STUFF IN HERE</frame><br> <br> <frame name="langFrame" src="lang.html">STUFF IN HERE</frame><br> <frame src="" id="main_ID" name="main" noresize>STUFF IN HERE THAT I<br> WANT</frame><br> </frameset><br> <br> <noframes><br> STUFF IN HERE<br> </noframes><br> <br> </html><br> <br> <br> I cannot access any forms etc included in the frame unless I can<br> name / access the frame.<br> Any ideas?<br> <br> Dan Martin<br> GP Hospital Practitioner<br> Computer Scientist<br> <a href="mailto:ummar143@shaw.ca" target="_blank">ummar143@shaw.ca</a><br> (204) 831-1746<br> answering machine always on<br> <br> _______________________________________________<br> Roundtable mailing list<br> <a href="mailto:Roundtable@muug.mb.ca" target="_blank">Roundtable@muug.mb.ca</a><br> <a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br> </blockquote></div><br><br clear="all"><br>-- <br>Sean Walberg <<a href="mailto:sean@ertw.com" target="_blank">sean@ertw.com</a>> <a href="http://ertw.com/" target="_blank">http://ertw.com/</a><br> </div> _______________________________________________<br> Roundtable mailing list<br><a href="mailto:Roundtable@muug.mb.ca" target="_blank">Roundtable@muug.mb.ca</a><br><a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br> </blockquote></div><br><div> <span style="font-size:12px"><div style="word-wrap:break-word"><span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word"> <div>Dan Martin</div><div><div style="word-wrap:break-word"><div style="word-wrap:break-word"><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">GP Hospital Practitioner</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"> Computer Scientist</div><div><a href="mailto:ummar143@shaw.ca" target="_blank">ummar143@shaw.ca</a></div><div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">(204) 831-1746</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"> answering machine always on</div></div></div></div></div></div></span></div></span> </div><br></div></div></div></div><br>_______________________________________________<br> Roundtable mailing list<br> <a href="mailto:Roundtable@muug.mb.ca">Roundtable@muug.mb.ca</a><br> <a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br> <br></blockquote></div><br><br clear="all"><br>-- <br>Sean Walberg <<a href="mailto:sean@ertw.com">sean@ertw.com</a>> <a href="http://ertw.com/">http://ertw.com/</a><br> </div> _______________________________________________<br>Roundtable mailing list<br><a href="mailto:Roundtable@muug.mb.ca">Roundtable@muug.mb.ca</a><br>http://www.muug.mb.ca/mailman/listinfo/roundtable<br></blockquote></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="font-size: 12px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Dan Martin</div><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; ">GP Hospital Practitioner</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; ">Computer Scientist</div><div><a href="mailto:ummar143@shaw.ca">ummar143@shaw.ca</a></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; ">(204) 831-1746</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; ">answering machine always on</div></div></div></div></div></div></span></div></span> </div><br></div></body></html>