Jump to content

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 post
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 post
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 post
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 post
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 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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By izmegna
      I am trying to auto login to web app that has the following HTML for the username, password and submit button:
      USERNAME:
      <input name="usernameField" tabindex="0" class="inp" id="usernameField" type="text" value="" message="FND_SSO_USER_NAME">
      Password:
      <input name="passwordField" tabindex="0" class="inp" id="passwordField" type="password" value="" message="FND_SSO_PASSWORD">
      Login:
      <button tabindex="0" class="OraButton left" style="padding-right: 6px; padding-left: 6px;" onclick="submitCredentials()" message="FND_SSO_LOGIN">Log In</button>
      Following is the AutoIT script I am using I am passing the username and password via cmd but it is not working, any suggestion?
       
      #include <IE.au3>
      Local $url ="https://www.Intra.edwa.com"
      Local $oIE =_IECreate($url)
      _IELoadWait($oIE)
      Local $oUser =_IEGetObjById($oIE,"usernameField")
      Local $oPass =_IEGetObjById($oIE,"passwordField")
      _IEFormElementSetValue($oUser, $CmdLine[1])
      _IEFormElementSetValue($oPass, $CmdLine[2])
      _IELoadWait($oIE)
      $oLinks = _IETagNameGetCollection($oIE, "input")
      For $oLink In $oLinks
          If String($oLink.type) = "submit" And String($oLink.value) = "Sign In" Then
                _IEAction($oLink, "click")
                ExitLoop
          EndIf
      Next
    • By noellarkin
      This is for those pages that seem to load when you use _FFOpenURL(), but they have a text saying "please wait while we load your page..." but according to _FFOpenURL() the page has loaded.  An example seen in popular sites is the Cloudflare page saying "Checking your browser before...". It's the opposite of pausing a script until an element is visible on a page. It takes Elements in the form of id, xpath or text search.
      Global $BrowserPort = 4242 Global $TimeOut = 60000 Global $LocalHost = "127.0.0.1" Func _FFWaitWhileElement($thiselement, $elementtype = "xpath", $timeoutms = 60000) _FFConnect($LocalHost, $BrowserPort, $TimeOut) Local $Element Local $ElementFound = 1 Local $TimeoutCountdown = 0 While $ElementFound <> 0 And $TimeoutCountdown < $timeoutms If $elementtype = "xpath" Then $Element = _FFXPath($thiselement) EndIf If $elementtype = "id" Then Local $ConstructXPath = ".//*[@id='" & $thiselement & "']" $Element = _FFXPath($ConstructXPath) EndIf ; MsgBox(0, "", $Element) Local $ElementXPathTextContent = _FFCmd("FFau3.xpath.textContent") ; MsgBox(0, "", $ElementXPathTextContent) Local $ElementXPathInnerHTML = _FFCmd("FFau3.xpath.innerHTML") ; MsgBox(0, "", $ElementXPathInnerHTML) If $ElementXPathTextContent = "_FFCmd_Err" Or $ElementXPathInnerHTML = "_FFCmd_Err" Then $ElementFound = 0 Else $ElementFound = 1 EndIf If $elementtype = "text" Then $ElementFound = _FFSearch($thiselement) ; MsgBox(0, "", $ElementFound) EndIf $TimeoutCountdown += 1000 _FFDisConnect() _FFConnect($LocalHost, $BrowserPort, $TimeOut) WEnd Return $ElementFound EndFunc _FFConnect($LocalHost, $BrowserPort, $TimeOut) _FFOpenURL("https://www.site.com/page", True) _FFWaitForElement("Please Wait...","text", 60000) MsgBox(0,"","Page finished loading") It's pretty simple, hope it helps some of you who are working with FF.au3 :)
    • By noellarkin
      So I was trying to write a function that can find a button (or any other XPath Element) and scroll the page + move the mouse to the location of the button.
      My logic for this was:
      1. get position of button using _FFGetPosition
      2. get inner dimensions of browser window and total dimensions of page
      3. divide total dimensions by inner dimensions to get number of page down operations
      4. use Mod() to get remaining pixels offset
      5. MouseMove() and add requisite offsets for Titlebar etc (what the +5 and +54 is for in the last line)
      Example Code:
      _FFConnect($LocalHost, $BrowserPort, $TimeOut) Local $Button = _FFXPath(".//*[@id='thisbutton']") Local $ButtonPosition = _FFGetPosition($Button) Local $ElementWidth = $ButtonPosition[0] Local $ElementHeight = $ButtonPosition[1] Local $InnerWidth = _FFCmd("window.content.innerWidth") Local $InnerHeight = _FFCmd("window.content.innerHeight") Local $PageWidth = _FFCmd(".body.offsetWidth") Local $PageHeight = _FFCmd(".body.offsetHeight") Local $PGDNNo = Int($ElementHeight/$InnerHeight) Local $PGDNMod = Mod($ElementHeight, $InnerHeight) ; MsgBox(0,"","$ElementX: " & $ElementWidth & @CRLF & "$ElementY: " & $ElementHeight) ; MsgBox(0,"","$InnerWidth: " & $InnerWidth & @CRLF & "$InnerHeight: " & $InnerHeight) ; MsgBox(0,"","$PageWidth: " & $PageWidth & @CRLF & "$PageHeight: " & $PageHeight) ; MsgBox(0,"",$PGDNNo) ; MsgBox(0,"",$PGDNMod) Local $iter = 1 While $iter <= $PGDNNo WinActivate($BrowserWindowClass,"") _FFCmd("window.content.scrollByPages(1)") $iter += 1 WEnd MouseMove($ElementWidth + 5, $PGDNMod + 54) This isn't working. In some cases, it's not doing the page down operation the number of times needed, or not accurately pinpointing the location. I think there may be something wrong with the logic I'm using. What am I doing wrong?
      Thanks.
       
    • By mLipok
      Anybody could help with using QueryInterface in AutoIt to embed Microsoft Edge using WebView2 Interface ?
      Here are links to information/documentation:

      Image comes from: https://docs.microsoft.com/en-us/microsoft-edge/webview2/media/webview2/whatwebview.png
      Introduction to Microsoft Edge WebView2
      https://docs.microsoft.com/en-us/microsoft-edge/webview2/

      Understand WebView2 SDK versions
      https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/versioning
      Download:
      https://developer.microsoft.com/en-US/microsoft-edge/webview2/
      https://developer.microsoft.com/en-US/microsoft-edge/webview2/#download-section
      https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution
      API Reference:
      https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/?view=webview2-1.0.622.22

      HowTo/Concepts:
      https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/versioning
      https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/win32
      https://docs.microsoft.com/en-us/microsoft-edge/webview2/howto/debug?tabs=devtools
      https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/security
      https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/userdatafolder
      https://mybuild.microsoft.com/sessions/9198aeac-0c8e-4d32-96d1-cbb99a390aa6
      Example:
      https://github.com/MicrosoftEdge/WebView2Samples
      Related:
      https://www.essentialobjects.com/Products/WebBrowser/Default.aspx?gclid=CjwKCAiA17P9BRB2EiwAMvwNyMe6UI9VHej-JYDBUoyGDFz40KaaJ_RidY-75Fhr-PHz65sSVC0XlxoC5loQAvD_BwE
      https://docs.microsoft.com/en-us/microsoft-edge/webview2/howto/webdriver
       
      btw.
      I'm not WindowsApi expert (QueryInterface, C++, DllCall).
      What I trying to say is:     It means that I do not done anything in this regards .... as so far.
       
       
      TIMELINE/ChangeLog:
       
      2020-11-12 - Project propsed by @mLipok 2021-02-03 - First version provided by @LarsJ
    • By vargheseg
      I have a web page which  has  somewhere from 90-100 records any time. So one has to scroll from from certain height to bottom using scroll bar on the right or using the down key. Is there any functionality to take a single screenshot and give .jpeg file.  Any previous links or direction will be very helpful for me
       
      George V
×
×
  • Create New...