beuy Posted July 30, 2009 Posted July 30, 2009 Hi there, I am looking to automate a daily task of logging into a website, entering a username and password, clicking on a series of links and a drop-down selection box, and then changing a text field. It was suggested to me that AutoIt could be used for this, however I am finding it hard to come across any instructions for creating such a script, could anyone provide some advice on how to go about this?
exodius Posted July 31, 2009 Posted July 31, 2009 Welcome to the forums!You most likely can do exactly what you're suggesting with AutoIt.Since you're tinkering with websites, I'd first recommend installing DebugBar(it's free and will help you identify webpage elements).Then look for these functions in your AutoIt HelpFile in the Index (they all have examples of their use):_IECreate_IEFormElementGetObjByName_IEFormElementSetValue_IEFormSubmit_IELinkClickByText_IEGetObjByNameIf you have problems, post what you come up with for code and I'm sure someone'll help!
beuy Posted August 3, 2009 Author Posted August 3, 2009 (edited) Hi there exodius, thanks for the great advice. I had a look into those functions and so far have: #include <IE.au3> $oIE = _IECreate ("https://10.1.2.10:8443/ccmuser") $oForm = _IEFormGetObjByName($oIE, "logonForm") $oQuery = _IEFormElementGetObjByName($oForm, "j_username") _IEFormElementSetValue ($oQuery, "hidden") $oQuery = _IEFormElementGetObjByName($oForm, "j_password") _IEFormElementSetValue ($oQuery, "hidden") _IEFormSubmit ($oForm) _IELoadWait ($oIE) _IELinkClickByText($oIE, "Device") _IEImgClick ($oIE, "Line Settings", "alt") _IELoadWait($oIE) $oForm = _IEFormGetObjByName($oIE, "linesettingsForm") $oQuery = _IEFormElementGetObjByName($oForm, "description") _IEFormElementOptionselect ($oQuery, "7499 - Line 8", 1, "byText") $oQuery = _IEFormElementGetObjByName($oForm, "cfadestination") _IEFormElementSetValue($oQuery, "7492") However it's throwing me for a loop here, it just refuses to update the "cfadestination" input with the next line, to make things even more confusing, it doesn't throw an error. HTML below: <input type="text" name="cfadestination" value="00425336814" onchange="javascript:iscfadestinationValid(this)"> Any ideas? Edited August 3, 2009 by beuy
exodius Posted August 3, 2009 Posted August 3, 2009 Does this do any better? #include <IE.au3> $oIE = _IECreate ("https://10.1.2.10:8443/ccmuser") $oForm = _IEFormGetObjByName($oIE, "logonForm") $oQuery = _IEFormElementGetObjByName($oForm, "j_username") _IEFormElementSetValue ($oQuery, "hidden") $oQuery = _IEFormElementGetObjByName($oForm, "j_password") _IEFormElementSetValue ($oQuery, "hidden") _IEFormSubmit ($oForm) _IELoadWait ($oIE) _IELinkClickByText($oIE, "Device") _IEImgClick ($oIE, "Line Settings", "alt") _IELoadWait($oIE) $oForm = _IEFormGetObjByName($oIE, "linesettingsForm") $oQuery = _IEFormElementGetObjByName($oForm, "description") _IEFormElementOptionselect ($oQuery, "7499 - Line 8", 1, "byText") $oQuery = _IEGetObjByName($oIE, "cfadestination") _IEFormElementSetValue($oQuery, "7492")
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now