Jump to content

invalid object type?


Sovereign
 Share

Recommended Posts

I have been automating IE for awhile now and thought I had pretty much figured out how the DOM works but I guess not. I have ran almost identical code on a different webpage and it worked fine but now it is having issues. Can anyone tell me what im missing?

$dfind = _IETagNameGetCollection($oIE, "div")
    for $d in $dfind
        if string($d.className) = 'contact vcard' Then
         msgbox(0,'',$d.innerhtml)
            $sfind = _IETagNameGetCollection($d, "div")
            msgbox(0,'',@error)

It correctly finds the first div tag collection and I am able to view its html but when I try to get the 2nd collection of div's within the original div it tells me $d is an invalid object type (error 4). I have done this successfully many times before so why is it all of the sudden giving me problems? The website im testing on is http://www.yellowbook.com/yellow-pages/?...Blackmon%20Agency&where=Birmin

This is just a small snippet of the code the actual For loop is to large to post

Edited by Sovereign
Link to comment
Share on other sites

I already have an error handler it doesn't have a critcal error the code just doesn't work right. I used IsObj($d) and it returned 1 so it is an object but for some reason _IETagNameGetCollection is saying its not valid... how is that possible?

I did Ubound($sfind) and its returning 0 so I checked the @error and its saying 0 which isn't even an option for Ubound I'm lost...

$dfind = _IETagNameGetCollection($oIE, "div")    ;Works perfect
    for $d in $dfind
        if string($d.className) = 'contact vcard' Then   ;Works perfect
            ;msgbox(0,'',$d.innerhtml)                              ;Works perfect and i see mutliple tags including div's
            ;msgbox(0,'',IsObj($d))                                   ; returns 1
            $sfind = _IETagNameGetCollection($d, "div")  ; fails with @error 4
            msgbox(0,'','ubound: ' & Ubound($sfind))         ; returns 0
            msgbox(0,'','ubnderror: ' & @error)  ;also returns 0
Edited by Sovereign
Link to comment
Share on other sites

I did Ubound($sfind) and its returning 0 so I checked the @error and its saying 0 which isn't even an option for Ubound I'm lost...

Every function resets @error, so you are checking @error on the MsgBox() :graduated:
Link to comment
Share on other sites

It is not an Array but a Collection. So you cant use Array functions on it.

$d.innerhtml - can you post the html of that?

<div class="bizName clearBlock">
            <h2>
                <a class="fn" title="View more information about Mr Pita" onclick="OmAdViewLeadClick('adsource: companyname', false, '1425', ';7;;;;evar33=inArea|evar34=2', '');" href="http://www.yellowbook.com/profile/mr-pita_1542139181.html?classid=7367">Mr Pita</a>
                                
            </h2>
            
            <div class="bizDist">
                <span>(1.23 miles)</span>
            </div>
            
        </div>
        
        
        <div class="bizAddr adr">
            <span id="lblAddress"><span class="street-address">27150 Evergreen Rd</span><br><span class="locality">Lathrup Village</span><span class="commaSep">, </span><span class="region">MI</span> <span class="postal-code">48076-3241</span></span> <a class="mapLink" href="http://www.yellowbook.com/directions/mr-pita_1542139181.html?from=28821+southfield+rd%2clathrup+village%2cmi%2c48076">(map)</a>
            <br class="clear">
        </div>
        
            <div class="bizPhone">
            
                <div class="call tel"><span>(248) 948-4100</span></div>
            
        </div>
        
        <div class="bizWeb">
            <a class="url" title="Go to the website for: http://www.mrpita.net" onclick="OmAdViewLeadClick('action click: website link', true, '5297', ';7;;;;evar33=inArea|evar34=2', '');PVifyExternalLink('img_external_1542139181_','/externaltracking?listingid=1542139181&amp;listingtype=businesslisting_free&amp;url=http%253a%252f%252fwww.mrpita.net');" href="http://www.mrpita.net" rel="nofollow" target="_blank">www.mrpita.net</a>
        </div>
Link to comment
Share on other sites

Hm - This should work. What version of IE are you using ? Try putting the site to trusted sites.

The new IE have some issues - try the compatibility mode.

Come to think of it I am using IE9 and I havn't ever used it before with autoit. I'll try compatibility mode if that doesn't work ill downgrade and see how that works.
Link to comment
Share on other sites

Try latest beta.

There was some rewriting of the IE.au3 code regarding this stuff. Compatibility mode should be avoided with automation.

Alright I'll check it out, i'm just using IE9 for testing the actual script will be running on a computer with IE7 which has never given me problems.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...