Jump to content

Simply need to click a webpage button


cassetcd
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

32 minutes ago, Danp2 said:

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

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
Link to comment
Share on other sites

  • Moderators

Notice the commented section below the MsgBox:

;_IEAction($oButton, 'click')

Try un-commenting

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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

 

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