Jump to content
Sign in to follow this  
Billy

Problem in _IEGetObjById

Recommended Posts

Billy

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?

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • SkysLastChance
      By SkysLastChance
      I am having a hard time understanding why this is not working. I was hoping some one could help explain it to me. 
      $tags = $oIE.document.GetElementsByTagName("input") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "fTs-p3298-l0 wplEditControl" Then $target = $tag ExitLoop EndIF Next MsgBox(0,"",$target) If $target = "fTs-p3298-l0 wplEditControl" THEN MsgBox(0,"","itworked") I have tried 
       MsgBox(0,"",$target.Attribute)  MsgBox(0,"",$target.Value)  MsgBox(0,"",$target.InnerText) I would expect to see this in the msgbox
      fTs-p3298-l0 wplEditControl  
    • SkysLastChance
      By SkysLastChance
      I am trying to grab the id "in2xk_26" however it the characters before the underscore always change. (in the name too)
      Is there a way I can find a id or name by the last 3 charcters?
      Using something like "stringright?"
      So I would want to search for just "_26" in this case.
      This is assuming that there are no other _26
       

      #include <Excel.au3> #include <IE.au3> #include <GUIConstantsEx.au3> Global $iMousespeed = 25,$target = "",$TagName = "",$Value = "",$Atrribute = "" $oIE = _IEAttach("MEDITECH") $TagName = "input" $Value = "in2xk_26" $Attribute = "id" $tags = $oIE.document.GetElementsByTagName($TagName) ;TagName ------ MAKE SURE TO NAME THESE For $tag in $tags $class_value = $tag.GetAttribute($Attribute) ;Attribute ------ MAKE SURE TO NAME THESE If string($class_value) = $Value Then ;Value ------ MAKE SURE TO NAME THESE $target = $tag $iScreenX = _IEPropertyGet($target, "screenx") $iScreenY = _IEPropertyGet($target, "screeny") $iWidth = _IEPropertyGet($target, "width") $iHeight = _IEPropertyGet($target, "height") $oMouseCords = MouseMove($iScreenX + $iWidth / 2, $iScreenY + $iHeight / 2, $iMousespeed) MouseClick($MOUSE_CLICK_LEFT) ExitLoop EndIf Next  
       
    • SkysLastChance
      By SkysLastChance
      I was wondering how I read data inside of a iframe. I would like to be able to click something inside a iframe. However, I can't even find the tag. 
      The id and name change all the time so I can't use those. 
      The code highlighted in blue is what I am trying to click. (second picture)
      Here is what I have tried.
      $target = "" $tags = $oIE.document.GetElementsByTagName("div") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "s_92 altstyle s_93 s_94" Then $target = $tag ConsoleWrite("Tag Found " & $target.outerText&@CRLF) ExitLoop EndIf Next  

       
       

    • SkysLastChance
      By SkysLastChance
       
      WinActivate("MEDITECH - Internet Explorer") Sleep (500) $oIE = _IEAttach("MEDITECH") $oDiv1 = _IEGetObjById($oIE, "sysmenu-searchbarbutton") _IEAction($oDiv1, "click") I am just trying to click the little magnifying glass, next to the gear button with no luck. I was hoping someone might have an idea why this is not working?
       

    • SkysLastChance
      By SkysLastChance
      I am trying to type a name in patient summary search box. How should I go about doing this. I am clearly not doing it right. (Attached Picture of HTML code.)
      This is what I have tried. I assume this is not working because it is not a form? 
      WinActivate("MEDITECH - Internet Explorer")       Sleep (500)    $oIE = _IEAttach("MEDITECH")    $oForm = _IEFormGetObjByName($oIE, "systemMenu")    $oText = _IEFormElementGetObjByName($oForm, "sysmenu-searchbarinput") _IEFormElementSetValue($oText, "Hey! This works!")
×