cassetcd Posted February 28, 2017 Share Posted February 28, 2017 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 More sharing options...
cassetcd Posted February 28, 2017 Author Share Posted February 28, 2017 Forgot to add I'm doing this in Internet Explorer. Link to comment Share on other sites More sharing options...
Danp2 Posted February 28, 2017 Share Posted February 28, 2017 You didn't show your code, so it leaves us guessing what you have already tried. Have you looked into _IEFormSubmit? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Subz Posted February 28, 2017 Share Posted February 28, 2017 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 More sharing options...
cassetcd Posted February 28, 2017 Author Share Posted February 28, 2017 (edited) 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 February 28, 2017 by JLogan3o13 Link to comment Share on other sites More sharing options...
cassetcd Posted February 28, 2017 Author Share Posted February 28, 2017 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) Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 28, 2017 Moderators Share Posted February 28, 2017 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 More sharing options...
cassetcd Posted February 28, 2017 Author Share Posted February 28, 2017 3 minutes ago, JLogan3o13 said: Notice the commented section below the MsgBox: ;_IEAction($oButton, 'click') Try un-commenting That certainly would help. I didn't see it until you pointed it out. Thanks! It works now. Link to comment Share on other sites More sharing options...
Danp2 Posted February 28, 2017 Share Posted February 28, 2017 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 SkysLastChance 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
junkew Posted February 28, 2017 Share Posted February 28, 2017 See frequently asked questions 31 when you want the answer for firefox chrome opera FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now