[RndTbl] trouble with Firewatir

Sean Walberg sean at ertw.com
Tue Apr 20 14:34:04 CDT 2010


There might be some session cookies or some javascript-fu going on that you
have to work around. If you're logging in, I'd be betting on the former.

Sean

On Tue, Apr 20, 2010 at 2:28 PM, Dan Martin <ummar143 at shaw.ca> wrote:

> I used a web page reference - consisting of variables enbedded in a URL -
> to "goto" the frame directly.  I can fill the login fields and click the
> button, but then I'm sent to another web page which is completely blank.
>
> I may have to skip the login altogether, and do it manually.  Hopefully I
> can still navigate within the web site.
>
> It wouldn't surprise me if the difficulty getting in is intentional - to
> discourage robots from guessing names and passwords.  But I had no trouble
> automating my access to a different financial institution's site.
>
> On 20-Apr-10, at 1:26 PM, Sean Walberg wrote:
>
> I mean to grab the page the frame references, instead of having Watir
> figure it out.
>
> I'm just trying to think what I'd do with Mech, as I've never heard of
> Watir until now.
>
> Sean
>
> On Tue, Apr 20, 2010 at 1:20 PM, Dan Martin <ummar143 at shaw.ca> wrote:
>
>> interesting - I get an "unknown frame exception" instead of an "unknown
>> object exception" using locate.
>>
>> >> browser.frame("main").locate()
>> Watir::Exception::UnknownFrameException: Unable to locate a frame using
>> name and main.
>> from
>> /Library/Ruby/Gems/1.8/gems/firewatir-1.6.5/lib/firewatir/elements/frame.rb:29:in
>> `locate'
>>  from (irb):66
>>
>> >> browser.frame("main").locate_frame(:name, 'main')
>> Watir::Exception::UnknownObjectException: Unable to locate element, using
>> :name, "main"
>>  from
>> /Library/Ruby/Gems/1.8/gems/firewatir-1.6.5/lib/firewatir/element.rb:907:in
>> `assert_exists'
>> from
>> /Library/Ruby/Gems/1.8/gems/firewatir-1.6.5/lib/firewatir/element.rb:1266:in
>> `method_missing'
>>  from (irb):64
>>
>> How would I open the frame directly?
>> The frame I want has an ID, even this doesn't help.
>>
>> An Xpath search fails:
>> >> browser.element_by_xpath('//*[@id="main_ID"]')
>> => #<FireWatir::Link:0x1a7fdcc located=false how=:jssh_name what=nil>
>>
>>
>> On 20-Apr-10, at 12:35 PM, Sean Walberg wrote:
>>
>> 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.
>>
>> 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.
>>
>> 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)
>>
>> Failing that, what about opening the frame directly?
>>
>> Sean
>>
>>
>>
>> On Tue, Apr 20, 2010 at 12:05 PM, Dan Martin <ummar143 at shaw.ca> wrote:
>>
>>> As noted in the previous email
>>> >> browser.frame("main")
>>> => #<FireWatir::Frame:0x1a90dd4 located=false how=:name what="main">
>>>
>>> "located=false" seems to be Firewatir's way of saying that the object
>>> doesn't exist until I ask for it.
>>> If I try to use it anyway, I get an unknown object exception
>>>
>>> >> browser.frame("main").html
>>> Watir::Exception::UnknownObjectException: Unable to locate element, using
>>> :name, "main"
>>>  from
>>> /Library/Ruby/Gems/1.8/gems/firewatir-1.6.5/lib/firewatir/element.rb:907:in
>>> `assert_exists'
>>> from
>>> /Library/Ruby/Gems/1.8/gems/firewatir-1.6.5/lib/firewatir/elements/frame.rb:34:in
>>> `html'
>>>  from (irb):62
>>>
>>> On 20-Apr-10, at 11:34 AM, Sean Walberg wrote:
>>>
>>>
>>> Looking at the rdocs, http://wtr.rubyforge.org/rdoc/1.6.5/, have you
>>> tried
>>>
>>> browser.frame("main").html
>>>
>>> ?
>>>
>>> On Tue, Apr 20, 2010 at 10:51 AM, Dan Martin <ummar143 at shaw.ca> wrote:
>>>
>>>> I am learning to navigate and scrape.  I have had more success with
>>>> Firewatir than Ruby mechanize, but both are poorly documented.
>>>>
>>>> Current problem:  logging into a site webpage, Firwatir can see the
>>>> frames, but cannot access them.
>>>>
>>>>  >> browser.show_frames
>>>> There are 3 frames
>>>> frame: name: topbar
>>>>       index: 1
>>>> frame: name: langFrame
>>>>       index: 2
>>>> frame: name: main
>>>>       index: 3
>>>> => 0..2
>>>>
>>>>  >> browser.frame(:index, 1)
>>>> => #<FireWatir::Frame:0x1a9260c located=false how=:index what=1>
>>>>
>>>>  >> browser.frame("main")
>>>> => #<FireWatir::Frame:0x1a90dd4 located=false how=:name what="main">
>>>>
>>>> Firefox shows the webpage source [I show only the top levels]
>>>> structure as:
>>>>
>>>> <html>
>>>>
>>>> <head>
>>>>        <meta http-equiv="content-type"
>>>> content="text/html;charset=iso-8859-1">
>>>>        <title>TITLE</title>
>>>>        <link rel="stylesheet" href="all.css">
>>>>
>>>>        <script language="JavaScript" src="WEBPAGE"></script>
>>>>        <script language="JavaScript">FUNCTIONS</script>
>>>> </head>
>>>>
>>>>        <frameset rows="63,0,*" border="0" id="frameset_ID"
>>>> framespacing="0"
>>>> frameborder="no" onload="loadHomepage(1);" onunload="forceLogout();">
>>>>                <frame src="/TDM/header.htm" name="topbar" scrolling="no"
>>>> noresize>STUFF IN HERE</frame>
>>>>
>>>>                <frame name="langFrame" src="lang.html">STUFF IN
>>>> HERE</frame>
>>>>                <frame src="" id="main_ID" name="main" noresize>STUFF IN
>>>> HERE THAT I
>>>> WANT</frame>
>>>>        </frameset>
>>>>
>>>>        <noframes>
>>>>                STUFF IN HERE
>>>>        </noframes>
>>>>
>>>> </html>
>>>>
>>>>
>>>> I cannot access any forms etc included in the frame unless I can
>>>> name / access the frame.
>>>> Any ideas?
>>>>
>>>> Dan Martin
>>>> GP Hospital Practitioner
>>>> Computer Scientist
>>>> ummar143 at shaw.ca
>>>> (204) 831-1746
>>>> answering machine always on
>>>>
>>>> _______________________________________________
>>>> Roundtable mailing list
>>>> Roundtable at muug.mb.ca
>>>> http://www.muug.mb.ca/mailman/listinfo/roundtable
>>>>
>>>
>>>
>>>
>>> --
>>> Sean Walberg <sean at ertw.com>    http://ertw.com/
>>>  _______________________________________________
>>> Roundtable mailing list
>>> Roundtable at muug.mb.ca
>>> http://www.muug.mb.ca/mailman/listinfo/roundtable
>>>
>>>
>>>  Dan Martin
>>> GP Hospital Practitioner
>>> Computer Scientist
>>> ummar143 at shaw.ca
>>> (204) 831-1746
>>> answering machine always on
>>>
>>>
>>> _______________________________________________
>>> Roundtable mailing list
>>> Roundtable at muug.mb.ca
>>> http://www.muug.mb.ca/mailman/listinfo/roundtable
>>>
>>>
>>
>>
>> --
>> Sean Walberg <sean at ertw.com>    http://ertw.com/
>>  _______________________________________________
>> Roundtable mailing list
>> Roundtable at muug.mb.ca
>> http://www.muug.mb.ca/mailman/listinfo/roundtable
>>
>>
>>  Dan Martin
>> GP Hospital Practitioner
>> Computer Scientist
>> ummar143 at shaw.ca
>> (204) 831-1746
>> answering machine always on
>>
>>
>> _______________________________________________
>> Roundtable mailing list
>> Roundtable at muug.mb.ca
>> http://www.muug.mb.ca/mailman/listinfo/roundtable
>>
>>
>
>
> --
> Sean Walberg <sean at ertw.com>    http://ertw.com/
>  _______________________________________________
> Roundtable mailing list
> Roundtable at muug.mb.ca
> http://www.muug.mb.ca/mailman/listinfo/roundtable
>
>
> Dan Martin
> GP Hospital Practitioner
> Computer Scientist
> ummar143 at shaw.ca
> (204) 831-1746
> answering machine always on
>
>
> _______________________________________________
> Roundtable mailing list
> Roundtable at muug.mb.ca
> http://www.muug.mb.ca/mailman/listinfo/roundtable
>
>


-- 
Sean Walberg <sean at ertw.com>    http://ertw.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.muug.mb.ca/pipermail/roundtable/attachments/20100420/88d43a27/attachment.html 


More information about the Roundtable mailing list