Jump to content

Recommended Posts

Posted

Hello all, 

I am brand-new to scripting and I have stumbled my way through filling the sign in boxes on a webpage, but I can't figure out how to click the Log In button other than with MouseClick, and that breaks when the user changes the size of the window. This is one of the last elements I'm missing; can someone help me out?

The log in button I need to click is on this page: 

https://www.asrpro.com/Login.aspx

 

Thanks!

Chad

Posted

Welcome to AutoIt please try:

#include <IE.au3>

;~ Connect to the site
Local $oIE = _IECreate("https://www.asrpro.com/Login.aspx", 1)
;~ Wait for the site to load
_IELoadWait($oIE)
;~ Get all Inputs
Local $oInputs = _IETagNameGetCollection($oIE, "Input")
For $oInput In $oInputs
    ;~ Fill in Username Field
    If $oInput.id = 'username' Then $oInput.value = 'Username'
    ;~ Fill in Password Field
    If $oInput.id = 'password' Then $oInput.value = 'Password'
    ;~ Fill in Id Field
    If $oInput.id = 'context' Then $oInput.value = 'Id#'
Next
;~ Get all Buttons
Local $oButtons = _IETagNameGetCollection($oIE, "Button")
For $oButton In $oButtons
    ;~ Check if Button InnerText equals Log In and perform an action.
    ;~ Uncomment the _IEAction line below to submit the form.
    If $oButton.InnerText = 'Log In' Then
        MsgBox(64, 'Log In Button Found', 'Button found with value: ' & $oButton.InnerText)
        ;_IEAction($oButton, 'click')
    EndIf
Next

 

Posted (edited)
  On 2/28/2017 at 4:42 PM, Danp2 said:

You didn't show your code, so it leaves us guessing what you have already tried. Have you looked into _IEFormSubmit?

Expand  

Here's the whole thing as it currently stands; it logs into the site and opens the page I need displayed:

 

#include <IE.au3>

Call ("SignIn")

Func SignIn ()

Global $oIE = _IECreate ("https://www.asrpro.com/Login.aspx")
Local $username = _IEGetObjByName ($oIE, "username")
Local $password = _IEGetObjByName ($oIE, "Password")
Local $context = _IEGetObjByName ($oIE, "Context")

_IEFormElementSetValue ($username, "myname")
_IEFormElementSetValue ($password, "myPassword")
_IEFormElementSetValue ($Context, "myID")

WinSetState ( "Inspect - Internet Explorer", "", @SW_MAXIMIZE)


MouseClick ("left", 970, 725)

Sleep (5000)

_IENavigate ($oIE, "https://www.asrpro.com/Parts/Dashboard")



EndFunc

 

 

Edited by JLogan3o13
Posted

Subz, 

 

When I paste your code and use my login info I get the MsgBox pop up: Button found with value: Log in but the button isn't clicked (i.e. nothing else happens)

Posted

Here's the "traditional" method --

#include <IE.au3>

SignIn()

Func SignIn ()

Global $oIE = _IECreate ("https://www.asrpro.com/Login.aspx")

Local $oForm = _IEFormGetCollection($oIE, 0)
Local $username = _IEFormElementGetObjByName ($oForm, "username")
Local $password = _IEFormElementGetObjByName ($oForm, "Password")
Local $context = _IEFormElementGetObjByName ($oForm, "Context")

_IEFormElementSetValue ($username, "myname")
_IEFormElementSetValue ($password, "myPassword")
_IEFormElementSetValue ($Context, "myID")

_IEFormSubmit($oForm)

EndFunc

 

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.
×
×
  • Create New...