Jump to content

Advanced login form


Recommended Posts

Good morning dear fellow scripters,

 

WIth help of the forum search function and the autoit help file i came up with the following code:

 

#include <IE.au3>
Opt("WinTitleMatchMode", 0)
$oIE = _IECreate ("https://www.klikvoorwonen.nl/mijn-klik-voor-wonen/inloggen/")
;~ Sleep(2000)

$o_form = _IEFrameGetObjByName ($oIE, "loginForm")
$o_login = _IEFormElementGetObjByName ($o_form, "username")
;~ $o_login = _IEGetObjById ($o_form, "username")
$o_password =_IEFormElementGetObjByName ($o_form, "password")
;~ $o_password = _IEGetObjById ($o_form, "password")

$username = "test"
$password = "test"

_IEFormElementSetValue ($o_login, $username)
_IEFormElementSetValue ($o_password, $password)

WinSetState ( "Internet", "", @SW_MAXIMIZE )

As you can see i tried both the frame method as the form method. Sadly to say, both did not work.

Appreciate any pointer to an efficient solution. (Other then using the mouseclick method)

Thanks in advanced for the creative mind that can solve this one. You rock!

Link to comment
Share on other sites

Every function returns errors by either setting the return value or the macros @error and/or @extended.
So please make sure every _IE* functions runs without errors.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

This works :

#include <IE.au3>

$oIE = _IECreate ("https://www.klikvoorwonen.nl/mijn-klik-voor-wonen/inloggen/")
Sleep(2000)
$o_login = _IEGetObjById ($oIE, "username")
ConsoleWrite ("username " & IsObj($o_login) & @CRLF)
$o_password = _IEGetObjById ($oIE, "password")
ConsoleWrite ("password " & IsObj($o_password) & @CRLF)

$username = "test"
$password = "test"

_IEFormElementSetValue ($o_login, $username)
_IEFormElementSetValue ($o_password, $password)

 

Link to comment
Share on other sites

hello fellow scripters,

yes you both are right, and i leaned some more tricks in the mean time. The code below finds both input fields and assign them accordingly to an object then tries to send out the form. There is one big obstacle we still got to tackle. The error handling on there website refrains the script below to send out the form.  (It thinks the input fields are empty)

Any ideas?

#include <IE.au3>

Local $oUser, $oPass, $oSubmit
Local $sUser = "testUsername"
Local $sPass = "testPassword"
Local $url = "https://www.klikvoorwonen.nl/mijn-klik-voor-wonen/inloggen/"
Local $oIE = _IECreate($url, 1)

_IELoadWait($oIE)

$oInputs = _IETagNameGetCollection($oIE, "input")
for $oInput in $oInputs
    if $oInput.type = "text" And $oInput.name = "username" Then $oUser = $oInput
    if $oInput.type = "password" And $oInput.name = "password" Then $oPass = $oInput
    if $oInput.type = "submit" And $oInput.value = "Inloggen" Then $oSubmit = $oInput
    if isObj($oUser) And isObj($oPass) And isObj($oSubmit) then exitloop
Next

$oUser.value = $sUser
$oPass.value = $sPass

_IEAction($oSubmit, "click")
_IELoadWait($oIE)

 

 

 

Link to comment
Share on other sites

With my code, I see the changes occurring in the fields.

image.png.25f6b95e94df4bb57176bd7e48d329a0.png

If you want to set value like you did, you need to fire events :

$oObject.fireEvent("OnChange")
$oObject.fireEvent("OnClick")

 

Edited by Nine
Link to comment
Share on other sites

Hi Nine, i did not need to add the fireEvent code to my code to make it work. Seems like both our codes do the job filling the in the input fields.

The next problem i stumble up is that after i submit the form, it wont actually submit.

Because the underlying code on the form thinks that the input fields are empty while they are not!?

 

I checked there website source code and i think it has something to do with the code below:

errorcode.png.2586915c529e91bc59ca60a01efc775e.png

Not sure how to solve this!?

Edited by Flum
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...