Sign in to follow this  
Followers 0
beuy

Script to login to web ui and make change

4 posts in this topic

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?

Share this post


Link to post
Share on other sites



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

_IEGetObjByName

If you have problems, post what you come up with for code and I'm sure someone'll help!

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by beuy

Share this post


Link to post
Share on other sites

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")

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  
Followers 0