Jump to content

Automate login


Recommended Posts

Hi,

I am looking for a way to automate login to a Internet Banking website (https://bank.tymedigital.co.za/) and all of the examples that I could found still do not solve my issue with this website.

In order to Login, the user need to enter their Identity Number and Password the click the Login button.

Inspecting the Elements in Chrome are as follow;

Identity Number

<input autocomplete="username" placeholder="Please enter your South African ID number" maxlength="13" type="tel" class="form-control" value="">

Password

<input autocomplete="current-password" placeholder="Enter password" type="password" class="form-control" value="">

Button

<button type="button" class="btn btn-yellow btn-block">Login</button>

Any assistance or directing me to a solution will be appreciated.

Thank you,

Lourens

Link to comment
Share on other sites

Looks like there is only one form, so look at form _IEFrameGetCollection

Then there is IETagNameGetCollection with "input". 

I am too tired to test your site, maybe tomorrow...

 

Link to comment
Share on other sites

10 minutes ago, Danp2 said:

Hi @Lourens,

Welcome to the forum. Please post additional details so that we can better understand the issue. Things like --

  • Which browser you are using
  • What isn't working as expected?
  • Post your code (use the <> icon at the top of the editor)

 

Browser - Internet Explorer

The form fields has no name or id and I can not use _IEGetObjByName or _IEGetObjById

Usually I would use _IEGetObjByName and set the value of the form field with _IEFormElementSetValue as below;

Local $oUsername = _IEGetObjByName($oIE, "username")
    Local $oPassword = _IEGetObjByName($oIE, "password")

    _IEFormElementSetValue($oUsername, "username")
    _IEFormElementSetValue($oPassword, "password")

Since _IEGetObjByType is not an option, I do not know how to proceed. Using _IEFormGetCollection inform me that there is one form on the page, however, no other useful information is returned that I can use (or I am doing something that I am not suppose to do).

Thank you,

Lourens

Link to comment
Share on other sites

 

I have found another script by @funkey

I have modified the script, however, the form does not recognize the values submitted even though it is visible in the form fields.

#include <IE.au3>

$Url = 'https://bank.tymedigital.co.za/'
$User = '0000000000000'
$Pwd = 'This_Is_Not_The_Password'

$test = _IEAutoLogin($Url, $User, $Pwd)

Func _IEAutoLogin($sUrl, $sUsername, $sPwd)

    $oIE = _IECreate($sUrl)
    _IEErrorNotify(False)
    _IEErrorHandlerRegister()
    $oForms = _IEFormGetCollection($oIE)
    If @error Then
        Return SetError(1, _IEErrorHandlerDeRegister(), $oIE)
    Else
        $Index = 0
        For $oForm In $oForms
            $oFormElements = _IEFormElementGetCollection($oForm)
            If IsObj($oFormElements) Then
                $IndexElement = 0
                For $oElement In $oFormElements

                    For $i = $IndexElement - 1 To 0 Step -1
                        $oPwd = _IEFormElementGetCollection($oForm, $i)
                        If $oPwd.Type = 'password' Then
                            _IEFormElementSetValue($oPwd, $sPwd)
                            ExitLoop
                        EndIf
                    Next

                    For $i = $IndexElement - 1 To 0 Step -1
                        $oUser = _IEFormElementGetCollection($oForm, $i)
                        If $oUser.Type = 'tel' Then
                            _IEFormElementSetValue($oUser, $sUsername)
                            ExitLoop
                        EndIf
                    Next

                    For $i = $IndexElement + 1 To $IndexElement + 10
                        $oButton = _IEFormElementGetCollection($oForm, $i)
                        If $oButton.Type = 'button' Then
                            _IEAction($oButton, "click")
                            ExitLoop
                        EndIf
                    Next

                    $IndexElement += 1
                Next
            EndIf
            $Index += 1
        Next
    EndIf
EndFunc   ;==>_IEAutoLogin

 

Attached is a screen shot of the error - it still produce the same error whether a valid id number is submitted or not. When an invalid values are submitted the error will be "Invalid SAID or password".

Thank you,

Lourens

tymedigital.PNG

Edited by Lourens
Part of explanation lost on posting.
Link to comment
Share on other sites

Right... I was just testing with this --

#include <IE.au3>

$oIE = _IECreate("https://bank.tymedigital.co.za/)")
$oForm = _IEFormGetCollection($oIE, 0)
$oUser = _IEFormElementGetCollection($oForm, 0)
$oPass = _IEFormElementGetCollection($oForm, 1)
_IEFormElementSetValue($oUser, "12345678")
_IEFormElementSetValue($oPass, "abcdefgh")
_IEFormSubmit($oForm)

It's possible that there is underlying events that need to be triggered for the login to work correctly.

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...