Jump to content

Fill in form in Frameset


webbit
 Share

Recommended Posts

Hello!

I want to control a device with Web page automation using AutoIt

My full application consists of buttons and an Internat Explirer Embedded instance, hidden from view (outside the Main Form boundaries)

The device webpage requires the Usage of FRAMESET, either provided by the device or created by Autoit Code

When i control the Web page without Frames, i am able to Fill in the form and submit.

Altought there is an unwanted popup afterwards (this is why using FRAMESET is better, since the pupop appears in the second Frame)

So i put my full application aside and tested bits of code in a small app... Here it is (with some explanations )

Note: I tested with Public Websites, since the Device to control is not available on the Net!!! :-)

; with no frames
#include <IE.au3>
dim $page1="http://www.imdb.com"
dim $page2="http://www.tigerdirect.ca"
$oIE = _IECreate ()
_IENavigate ($oIE, "http://www.imdb.com")
_IELoadWait ($oIE)
$oForm = _IEFormGetCollection ($oIE, 0)
dim $oQuery = _IEFormElementGetCollection ($oForm, 1)
_IEFormElementSetValue ($oQuery, "banana")
exit

This easily navigates to the IMDB page and writes the Work banana in the Search textbox

altough, when i put the same thing in a frameset, it does not work...

; with frames
#include <IE.au3>
_IEErrorHandlerRegister()
dim $page1="http://www.imdb.com"
dim $page2="http://www.red.com/"
$oIE = _IECreate ()
$sHTML = "<HTML><HEAD></HEAD><FRAMESET rows=*,99><FRAME border=0 name=mainFrame src=" & chr(34) & $page1 & chr(34) & " frameBorder=0><FRAME name=resultFrame src=" & chr(34) & $page2 & chr(34) & " frameBorder=1></FRAMESET></HTML>"
_IEDocWriteHTML ($oIE, $sHTML)
_IEAction ($oIE, "refresh")
_IELoadWait ($oIE)
DIM $oFrame = _IEFrameGetObjByName($oIE, "mainFrame")
$oForm = _IEFormGetCollection ($oFrame, 0) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;This line throws an error
dim $oQuery = _IEFormElementGetCollection ($oForm, 1)
_IEFormElementSetValue ($oQuery, "banana")
exit

i get this error (when i hit the This line throws an error)

--> COM Error Encountered in Tester.au3
----> $IEComErrorScriptline = 2214
----> $IEComErrorNumberHex = 80020009
----> $IEComErrorNumber = -2147352567
----> $IEComErrorWinDescription = Accès refusé.
----> $IEComErrorDescription = Accès refusé.
----> $IEComErrorSource =
----> $IEComErrorHelpFile = C:\Windows\System32\mshtml.hlp
----> $IEComErrorHelpContext = 0
----> $IEComErrorLastDllError = 0
--> COM Error Encountered in Tester.au3
----> $IEComErrorScriptline = 1076
----> $IEComErrorNumberHex = 000000A9
----> $IEComErrorNumber = 169
----> $IEComErrorWinDescription = Variable must be of type 'Object'.
----> $IEComErrorDescription = Accès refusé.
----> $IEComErrorSource =
----> $IEComErrorHelpFile = C:\Windows\System32\mshtml.hlp
----> $IEComErrorHelpContext = 0
----> $IEComErrorLastDllError = 0
--> COM Error Encountered in Tester.au3
----> $IEComErrorScriptline = 1076
----> $IEComErrorNumberHex = 000000A9
----> $IEComErrorNumber = 169
----> $IEComErrorWinDescription = Variable must be of type 'Object'.
----> $IEComErrorDescription = Accès refusé.
----> $IEComErrorSource =
----> $IEComErrorHelpFile = C:\Windows\System32\mshtml.hlp
----> $IEComErrorHelpContext = 0
----> $IEComErrorLastDllError = 0
--> IE.au3 V2.4-0 Warning from function _IEFormGetCollection, $_IEStatus_NoMatch
--> IE.au3 V2.4-0 Error from function _IEFormElementGetCollection, $_IEStatus_InvalidDataType
--> IE.au3 V2.4-0 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType

It seems i am unable to act on the first frame...

altough if i use this code..

DIM $oFrame = _IEFrameGetObjByName($oIE, "mainFrame")
_IENavigate ($oFrame, "http://www.yahoo.com")

i am able to control the frame.

I dont see what is the difference between the two...

Hope someone can help me! I must be missing a bit of understanding...

Link to comment
Share on other sites

OK, my example may not be as good as i tought...

I may be problematic that i choose 2 different website, this may cause Cross domain scripting limitation

but in fact the device i want to control using Web page automation , the 2 pages that fills the 2 frames come from the same sie/domain.

i have the same problem with local HTML coming from hard drive (no local web server)

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