Reputation: 117
I have been struggling over the past 48 hours to create a script that can do some basic things within internet explorer:
I have no problem logging into the website, but I cannot seem to get the menus working once I am logged in. I have a feeling this is to do with them being dynamically created but my html experience is very limited so I do not know for sure. I have tried a range of different functions(_IEFormElementGetObjByName,_IEFormGetCollection,_IEFormGetObjByName) among others but cannot seem to make it work. I cannot post the full script as it contains passwords that I cannot post publicly, but here it is with user/password removed:
;Created by SYD-JAMEST from code found at:
;http://solubletech.blogspot.com.au/2011/02/use-autoit-v3-to-make-auto-login-script.html
#Region ;*** Variables
Const $DispatchSite = "https://equipmentrepaircas.interasset.com/cas/login?service=https%3A%2F%2Fwww.iasdispatchmanager.com%2Fdispatchmanager%2Fj_acegi_cas_security_check"
Const $uname="user"
Const $pwd="pass%"
#EndRegion
#include <ie.au3>
;*** Navigate to Dispatch Manager and login with username & password
$oIE = _IECreate ($DispatchSite)
$oForm = _IEFormGetObjByName ($oIE, "fm1")
$oQuery1 = _IEFormElementGetObjByName ($oForm, "username")
$oQuery2 = _IEFormElementGetObjByName ($oForm, "password")
_IEFormElementSetValue ($oQuery1,$uname)
_IEFormElementSetValue ($oQuery2,$pwd)
$oButton=_IEGetObjByName($oIE,"submit")
_IEAction ($oButton, "click")
_IELoadWait($oIE,0)
;** This is the section I cannot get to work
$oForm1 = _IEFormGetObjByName ($oIE, "isc_historyForm")
$test = _IEGetObjById($oForm1, "isc_1F")
$oMenu = _IEGetObjById ($oForm1,"isc_MenuBarButton_0") ;isc_MenuBarButton_0
;$oMenu = _IEGetObjById ($oForm1,"isc_1E")
_IEAction ($test, "focus")
This is the html of the area I am trying to access - It doesn't show a name, nor any of the dropdown options that show on screen when selected.
<div id="isc_1E" eventproxy="isc_MenuBarButton_0" style="position: absolute; left: 195px; top: 0px; width: 150px; height: 24px; z-index: 200810; overflow: hidden; cursor: pointer; -webkit-margin-before-collapse: collapse; -webkit-margin-after-collapse: collapse;" onscroll="return isc_MenuBarButton_0.$lh()" onfocus="isc.EH.focusInCanvas(isc_MenuBarButton_0,true);" onblur="if(window.isc)isc.EH.blurFocusCanvas(isc_MenuBarButton_0,true);" tabindex="-1" role="button" aria-haspopup="true"><table cellspacing="0" cellpadding="0" width="150" height="24" style="table-layout:fixed"><tbody><tr><td class="menuButton" style="padding-top:0px;padding-bottom:0px;text-align:center;vertical-align:middle"><div style="display:inline-block;max-width:100%;white-space:nowrap;vertical-align:middle"><div id="isc_1D" style="overflow:hidden;text-overflow:ellipsis;text-align:left"><img src="https://training.iasdispatchmanager.com/dispatchmanager/ias/images/icons/admin.png" align="TEXTTOP" border="0" suppress="TRUE"> <b>Admin</b></div></div></td></tr></tbody></table></div>
Upvotes: 0
Views: 1203
Reputation: 897
The second part cannot work. If you get a form object
$oForm1 = _IEFormGetObjByName ($oIE, "isc_historyForm")
you have to go on with the elements of this object, like it is done in the first (password) part of your script. So your next statement could be something like:
$oTest = _IEFormElementGetObjByName($oForm1, "isc_1F").
Load down the autoIt help file for "user defined function" and look over the examples for "ie-management". Here the definition and examples for the work with dropdown / select boxes. https://www.autoitscript.com/autoit3/docs/libfunctions/_IEFormElementOptionSelect.htm
You may try that. Best regards, Reinhard
Upvotes: 1