Jump to content

Values set by _IEFormElementSetValue not detected


Recommended Posts

I am trying to create an autologin script for a website we use at work.
Although the website is public, I  obfuscated the $url deliberately, so it won't show up in public  web searchs. 
Also username and password are not the working one¬†ūüėĀ

#include <IE.au3>

;$url is delibered obfuscated so it wont be indexed by searchrobots!!!
$url = "https://o" & "rdermanager." & "teca" & "llianc" & "e.net/new" & "app/" & "auth/login"
$oIE = _IECreate ($url,0,1,1)
$HWND = _IEPropertyGet($oIE, "hwnd")
WinActivate  ($HWND,"")
WinSetState($HWND, "", @SW_MAXIMIZE)


$oUsername = _IEGetObjById ($oIE,"login-txt-username")
$oPassword = _IEGetObjById ($oIE,"login-txt-password")

$oButton = _IEGetObjById ($oIE,"changepwd-btn-request")

_IEFormElementSetValue ($oUsername, "me@test.com")
_IEFormElementSetValue ($oPassword, "Test1234!")

_IEAction ($oButton, "click")

When running the above code, the fields are populated, however when [Login] button is "clicked" the fields wil show "This field is required".

Only when I add a charachter manually and remove that character  for each field, the page will update the values internally.

  1. Could some tell me a way to fix this?
  2. The cookie button on the top of the page does not have an ID, so I do not how to click on it from autoit.
    Is there another way to press this button ?

image.png.bc369c5f0f9aba0d49cfa143dce6a289.png

 

 

 

Edited by Jemboy
to many images uploaded
Link to comment
Share on other sites

You have to trigger an "input" event on each of the input elements. The following code works for me --

#include <IE.au3>

$url = "https://o" & "rdermanager." & "teca" & "llianc" & "e.net/new" & "app/" & "auth/login"
$oIE = _IECreate($url)

$oDoc = _IEDocGetObj($oIE)
$oEvt = $oDoc.createEvent("HTMLEvents")
$oEvt.initEvent("input", True, False)

$oUsername = _IEGetObjById($oIE,"login-txt-username")
_IEFormElementSetValue($oUsername, "me@test.com")
$oUsername.dispatchEvent($oEvt)

$oPassword = _IEGetObjById($oIE,"login-txt-password")
_IEFormElementSetValue($oPassword, "Test1234!")
$oPassword.dispatchEvent($oEvt)

$oButton = _IEGetObjById($oIE,"changepwd-btn-request")
_IEAction($oButton, "click")

 

Link to comment
Share on other sites

@Danp2 Just checked your script and it is working like a charm!
I never really grasped objects (I am from the pre objects era), so for me it's like magic:sorcerer:
Thanks you for showing me the way at 2:30 am¬†ūüėČ

 

Link to comment
Share on other sites

  • 2 weeks later...

At the top of the page, there is a cookie acceptance button with the caption: "Got it!"
image.thumb.png.92cf68b8560154a225f599cd665a0cf4.png

After several hours searching on the forum, Google and just trial  and error, I manage to click the "Got it!"-button with the following lines:

Local $oTags = _IETagNameGetCollection($oIE, "a")
For $oTag In $oTags
    If $oTag.InnerText="Got it!" Then
        _IEAction($oTag, "click")
        ExitLoop
    EndIf
Nex

The above snippet works, however does anyone knows a "cleaner" way of hitting that button?

 

Link to comment
Share on other sites

On 5/25/2020 at 1:34 AM, Danp2 said:

IELinkClickByText

_IELinkClickByText($oIE, "Got it!")

Tried the above, alas it did¬†not work. It would however been extremely "clean", replacing all those lines by only oneūüėĀ
BTW, did you know that the second example of _IELinkClickByText in the help file, does not has _IELinkClickByText in it?:muttley:
I think it is intended though.
 

Just changed the earlier enumeration with the following code.

$oElements = _IETagNameAllGetCollection($oIE)
For $oElement In $oElements
    If $oElement.GetAttribute("aria-label")="dismiss cookie message" Then _IEAction($oElement, "click")
Next

Found this solution more universal and making the check more unique by  checking on a rare attribute (in this case: "aria-label").

Edited by Jemboy
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

×
×
  • Create New...