Jump to content

Framesets in IE


apstanto
 Share

Recommended Posts

I'm trying to do a button click on a webpage, but I can't figure out how to deal with framesets within one another. My program crashes at this code:

; Click Add
    $rightFrame = _IEFrameGetObjByName($IE_Window, "main")
    $addButton = _IEGetObjByName($rightFrame, "add")
    _IEAction($addButton, "click")

and SciTE keeps giving this error:

C:\Program Files (x86)\AutoIt3\Include\IE.au3 (2692) : ==> The requested action with this object has failed.:
Return SetError($_IEStatus_Success, 0, $o_object.location.href())
Return SetError($_IEStatus_Success, 0, $o_object.location.href()^ ERROR
->21:40:44 AutoIT3.exe ended.rc:1
>Exit code: 1    Time: 7.227

I'm searching the forums but can't find a solution to this. Any help would be great! I attached the HTML too. Thanks!

post-59763-12843543406308_thumb.png

Link to comment
Share on other sites

The cited line is from _IEPropertyGet() with "locationurl" inside the IE.au3 UDF.

So what makes you think it is failing within the three lines of code posted?

;)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Where do you get the error ? On the _IEaction line?

This error is from the IE UDF - if you double click on the error in Scite it will

pop-up IE.au3 on the error line. What IE and AU versions are you using ?

I think my IE version is 8, but I can't remember for sure and I can't check it at the moment. My AU3 version is v3.3.6.1. I think it fails on the IEGetObjByName line, but I'll double check.

The cited line is from _IEPropertyGet() with "locationurl" inside the IE.au3 UDF.

So what makes you think it is failing within the three lines of code posted?

;)

I'm assuming it's not a problem with IE.au3. I guess I could be wrong, but I'm new to manipulating webpages so I thought it was my problem. There are frames and framesets on the page that I'm not sure if I'm handling correctly.

Link to comment
Share on other sites

In your screenshot I see:

FrameSet --> FrameSet --> Frame "main" --> Form "Form1" --> Input "add"

In the code you posted, you only try to get one frame, then the Input tag without even referencing the Form. You might try something more like this:

_IEErrorHandlerRegister()

; ...

$oFrameSet1 = _IEFrameGetCollection($oIE, 0) ; First frameset (no name, by index)
$oFrameSet2 = _IEFrameGetCollection($oFrameSet1, 1) ; Second frame(set) under first frameset (no name, by index)
$oFrame = _IEFrameGetObjByName($oFrameSet2, "main") ; Second frame under second frameset (by name)
$oForm = _IEFormGetObjByName($oFrame, "Form1") ; Form under frame (by name)
$oInput = _IEFormElementGetObjByName($oForm, "add") ; Input tag under form (by name)

Note the addition of the error handler. Run it in SciTE and watch the console pane for error reports.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

In your screenshot I see:

FrameSet --> FrameSet --> Frame "main" --> Form "Form1" --> Input "add"

In the code you posted, you only try to get one frame, then the Input tag without even referencing the Form. You might try something more like this:

_IEErrorHandlerRegister()

; ...

$oFrameSet1 = _IEFrameGetCollection($oIE, 0) ; First frameset (no name, by index)
$oFrameSet2 = _IEFrameGetCollection($oFrameSet1, 1) ; Second frame(set) under first frameset (no name, by index)
$oFrame = _IEFrameGetObjByName($oFrameSet2, "main") ; Second frame under second frameset (by name)
$oForm = _IEFormGetObjByName($oFrame, "Form1") ; Form under frame (by name)
$oInput = _IEFormElementGetObjByName($oForm, "add") ; Input tag under form (by name)

Note the addition of the error handler. Run it in SciTE and watch the console pane for error reports.

;)

Wow, Thanks PsaltyDS! I was thinking I needed something along these lines, from reading the helpfile and other posts. I'll give this a try!
Link to comment
Share on other sites

In your screenshot I see:

FrameSet --> FrameSet --> Frame "main" --> Form "Form1" --> Input "add"

After playing around with it, I still can't get it to work. Although I got really close at one point. I tried the example code from the help file:

; *******************************************************
; Example 1 - Open frameset example, get collection of frames
;               and loop through them displaying their source URL's
; *******************************************************
;

; ...

$oFrames = _IEFrameGetCollection ($IE_Window)
$iNumFrames = @extended
For $i = 0 to ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection ($IE_Window, $i)
    MsgBox(0, "Frame Info", _IEPropertyGet ($oFrame, "locationurl"))
Next

When I run it, $iNumFrames is 3, which is correct. IEPropertyGet returns manage_T.asp, then manage_L.asp. So far so good, but then it should return manage_R.asp, but it throws these errors:

--> COM Error Encountered in MyScript.au3
----> $IEComErrorScriptline = 2692
----> $IEComErrorNumberHex = 80070005
----> $IEComErrorNumber = -2147024891
----> $IEComErrorWinDescription = Access is denied.
----> $IEComErrorDescription = 
----> $IEComErrorSource = 
----> $IEComErrorHelpFile = 
----> $IEComErrorHelpContext = 
----> $IEComErrorLastDllError = 0

+>21:38:52 AutoIT3.exe ended.rc:0
>Exit code: 0    Time: 13.038

It's interesting because I tried some variations, like:

$oFrames = _IEFrameGetCollection ($IE_Window)
$oFrame = _IEFrameGetCollection ($IE_Window, 2)
MsgBox(0, "Frame Info", _IEPropertyGet ($oFrame, "locationurl"))

which should show the url with "manage_R.asp" on the end. What's weird is it worked perfectly one time, showing me the correct "locationurl" for "manage_R.asp"!!! But I didn't change a thing, and now it's not working again. I kept trying, hoping to get a different result, but it's still broken. IEPropertyGet gives a blank MsgBox.

I'm still accessing the page with the HTML I attached to my first post. Anyone know why it's saying "Access is denied."? Thanks for any ideas!

Edit:

You might try something more like this:

PS, I did take all your suggestions and tried the code you posted, along with playing around with it to see if I could make it work. It also gave errors, so I'm thinking this problem has to do with the html page I'm trying to automate??? ;) Edited by apstanto
Link to comment
Share on other sites

Anyone know why it's saying "Access is denied."?

Cross-site scripting (XSS) protection. You can try getting the full URL to the failed frame reference and opening it directly in a separate instance of IE.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Cross-site scripting (XSS) protection. You can try getting the full URL to the failed frame reference and opening it directly in a separate instance of IE.

;)

So is it protection against XSS that is preventing me from getting the URL?

Also, wouldn't I use the _IEPropertyGet ($oFrame, "locationurl") to get the full URL? I couldn't get this to work in a message box. It comes out blank and throws the errors.

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...