Jump to content

Find input fields inside a frame - (Moved)


Bala98
 Share

Recommended Posts

I have a website that is using frames and I want to find the input fields inside the frame and autopopulate them with the autoitscript. Below is the page html:

<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <meta name="robots" content="noindex">
        <title>Site Name</title>
    </head>
    <frameset rows="*" framespacing="0" border="0" frameborder="no">
        <frame src="/userui/welcome.php" name="kbox" scrolling="auto" noresize="noresize">
    </frameset>
    <noframes>
        <body>
            <p>This site requires "frames" support by your browser.</p>
        </body>
    </noframes>
</html>

I am using below code to find out the field inside the frame but getting an error below.

---------------------------
AutoIt Error
---------------------------
Line 27  (File "D:\TestAgain.au3"):

for $oInput in $oInputs
for $oInput in $oInputs^ ERROR

Error: Variable must be of type "Object".
---------------------------
OK   
---------------------------

Code snippet:

Local $oIE = _IECreate($url)

_IELoadWait($oIE)

$frames = _IEFrameGetCollection($oIE);
$numFrames = @extended ; number of frames

For $i = 0 to ($numFrames -1)
    $oFrame = _IEFrameGetCollection($oIE, $i)

    $oInputs = _IEFormElementGetCollection($oFrame, "input")
    
    
for $oInput in $oInputs
    if $oInput.type = "text" And $oInput.name = "login"  Then $oUser = $oInput
    if $oInput.type = "password" And $oInput.name = "password"  Then $oPass = $oInput
    if $oInput.type = "submit" And $oInput.name = "save" Then $oSubmit = $oInput
    if isObj($oUser) And isObj($oPass) And isObj($oSubmit) then exitloop
Next

Would appreciate if someone can explain if this is correct way to navigate elements inside frames or there is another approach for it?

Link to comment
Share on other sites

1 hour ago, Danp2 said:

Check the value of @error after the call to _IEFormElementGetCollection.

Hint: Your 2nd parameter is wrong.

Hi Danp2,

The value of @error comes out as 4. Also updated the 2nd parameter as below:

$oFrame = _IEFrameGetCollection($oIE, $i)

    $oInputs = _IEFormElementGetCollection($oFrame, $i)

But I am still getting the same error " Error: Variable must be of type "Object". ".

Link to comment
Share on other sites

18 minutes ago, Danp2 said:

This should be changed to the following if your goal is to obtain a collection of elements --

$oInputs = _IEFormElementGetCollection($oFrame, -1)

 

I am still getting the same error on changing to below:

$oInputs = _IEFormElementGetCollection($oFrame, -1)

Link to comment
Share on other sites

Ok... then you'll need to do some debugging on your own since you haven't posted code that we can actually run.

Suggest that you check for @error following each call to an _IE* function.

P.S. Thinking about this further, I think you're passing the wrong object as the first parameter. This should be a form object, not a frame object.

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