Jump to content

IE automation questions


Go to solution Solved by DaleHohm,

Recommended Posts

I'm having issues using ie.au3 include. I cannot get autoit to fill in the username and password and then click submit

Website I'm trying to automate: https://test.lps-lqgateway.com/OrderSelection/InitialOrderSelection

Here is the code i have so far (pretty sure my syntax is wrong when using the _IEFormElementGetObjByName and _IEFormElementSetValue functions):

Let me know if more information is needed and thanks in advance for your help!

#include

$o_IE = _IECreate("https://test.lps-lqgateway.com/OrderSelection/InitialOrderSelection", 0, 1, 1, 1)
$o_login = _IEFormElementGetObjByName($o_IE, "UserName")
$o_password = _IEFormElementGetObjByName($o_IE, "Password")
_IEFormElementSetValue($o_login, "fake-username", 0)
_IEFormElementSetValue($o_password, "fake-password", 0)

Exit

HTML elements from IE_Builder2.0.1:

Link to comment
Share on other sites

  • Solution

Read the remarks in the helpfile for the function _IEFormElementGetObjByName

In addition to what it states there, you can use _IEGetObjByName

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Thank you for your reply and your work with the IE UDF!

I can't believe i missed that.

anyways for others reference - this is the working code (minus valid login information)

#include IE.au3

$o_IE = _IECreate("https://test.lps-lqgateway.com/OrderSelection/InitialOrderSelection", 0, 1, 1, 1)
$o_login = _IEGetObjByName($o_IE, "UserName")
$o_password = _IEGetObjByName($o_IE, "Password")
$o_loginbtn = _IEGetObjById($o_IE, "LogOn_btnSubmit")

_IEFormElementSetValue($o_login, "fake-username", 0)
_IEFormElementSetValue($o_password, "fake-password", 0)

_IEAction($o_loginbtn, "click") ; click login button

Exit
Edited by Shrapnel
Link to comment
Share on other sites

I can't believe i missed that.

You know, neither can I, but you're not alone. Glad you got it working.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

OK, now i ran into a new problem. Some of the text boxes i need to enter data into have a unique identifier added to the ID that changes every time you visit the site.

example:

ID of "OrderDataTitleAndClosing_Borrower_Party_txtFirstName" text box on 1st Visit :

4c5a786a-fa8b-4d82-b3d0-758068bb9181_OrderDataTitleAndClosing_Borrower_Party_txtFirstName_1

ID of "OrderDataTitleAndClosing_Borrower_Party_txtFirstName" text box on 2nd Visit:

7379915f-fa39-48fb-85fe-b738ff1f33f2_OrderDataTitleAndClosing_Borrower_Party_txtFirstName_1

Below is the code from the site. is there any way for me to reference the "originalid" when i use the _IEGetObjByID command?

<input class="Value_ControlL4 OrderDataTitleAndClosing_Borrower_Party_txtFirstName DuplicatedCheck" id="7379915f-fa39-48fb-85fe-b738ff1f33f2_OrderDataTitleAndClosing_Borrower_Party_txtFirstName_1" type="text" size="30" maxLength="30" autocomplete="off" required="required" originalid="OrderDataTitleAndClosing_Borrower_Party_txtFirstName" multiplepart="true" parentid="multic1389bb1-1322-4c78-833e-a4759b030930" multiplePartElem="true"/>
Link to comment
Share on other sites

Probably a salt to hinder automation.

Either that or it is trying to prevent duplicates. there is an "originalid" in the input tag with the value of "OrderDataTitleAndClosing_Borrower_Party_txtFirstName", which is what i think would solve my problem...if i can pull that information instead of the "ID".

I am messing around with the _IETagNameGetCollection function now to try to solve this problem

Link to comment
Share on other sites

I finally figured it out. This might not be the best way to go about it, but it works!

$o_borrower1FirstName = _IEGetObjById($o_IE, getID("input", "originalid=""OrderDataTitleAndClosing_Borrower_Party_txtFirstName""", " id=""", 5, 91))

_IEAction($o_borrower1FirstName, "focus")
Send("Joe") ; Set Borrower 1 first name

Exit

Func getID($_tagName, $_originalID, $_startString, $_startPosition, $_endPosition)
Local $oElements = _IETagNameGetCollection($o_IE, $_tagName)
For $oElement In $oElements
Local $_outerhtml = $oElement.outerhtml
If StringInStr($_outerhtml, $_originalID) Then
Local $id = StringMid($_outerhtml, StringInStr($_outerhtml, $_startString) + $_startPosition, $_endPosition)
;MsgBox(0, "Debug getID function", $html & @CR & @CR & $id) ; DEBUG
Return $id
EndIf
Next
EndFunc
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...