Jump to content

Problem in _IEGetObjById


Billy
 Share

Go to solution Solved by Danp2,

Recommended Posts

I am attempting to automate entry of data on an HTML form.  The actual entry is done in a subroutine as the actions are redundant.  The first time through, no problems.  Second time, problems:

--> IE.au3 T3.0-1 Error from function _IEGetObById, $_IESTATUS_InvalidObjectType
 

The section of HTML I am attempting to use:

<tr onclick="javascript:toggleblocks('table6','prodBlock6');">
   <td height="22" id="prodBlock6" name="Name of Item" colspan="2" class="prodsellclose">
      Name of Item
  </td>
</tr>

<tr width="100%">
   <td height=1 colspan="2">
      <table id="table6" width="100%" border="0" cellpadding="0" cellspacing="0" class="collapseblock">
         <TBODY>
            <tr width="100%" class="" id="Item1"
                 name="Item 1 Name"
                 onclick="selectProductForAdding(this.id, 'Item 1 Name', 'another Param')">
                 <td>Item 1 Name</td>
                 <td>99.99</td>
             </tr>
             
             <tr width="100%" class="" id="Item2"
                 name="Item 2 Name"
                 onclick="selectProductForAdding(this.id, 'Item 2 Name', 'another Param')">
                 <td>Item 2 Name</td>
                 <td>99.99</td>
             </tr>
             ...

My AutoIt code:

AddProduct("prodBlock", $product1, "someText")
AddProduct("prodBlock", $product2, "someText")

Func AddProduct($prodBlock, $product, $action="")
   ; $g_objForm below is global
   ; I've tried $IEelement as local and global, no diff
   $IEelement = _IEGetObjById($g_objForm, $prodBlock) ; this selects the displayed table row which opens a sub-menu
   $IEelement = _IEGetObjById($g_objForm, $product)   ; this selects the item in the sub-menu
   _IEAction($IEelement, "click")
   Sleep(2000)

   $IEelement = _IEGetObjById($g_objForm, "addButtonP") ; click a button
   _IEAction($IEelement, "click")
   Sleep(2000)

   If $action <> "" Then
      Switch $action
      Case "someText"
         $IEelement = _IEGetObjById($g_objForm, "ID_of_button_on_popup")
         _IEAction($IEelement, "click")
      EndSwitch
   EndIf

EndFunc

The goal is to select a row from a displayed table.  The table's javascript opens a sub-menu from which a selection is made then an "Add" button is clicked.  Then a javascript popup is displayed then dispatched by my script.  All done successfully.

On the second time through, I get the invalid object type error.

Ideas anyone?

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

×
×
  • Create New...