MITK Posted September 19, 2018 Share Posted September 19, 2018 let me start this by saying .. I am in no way a coder ... I have been asked by my company to come up with a method of automating the login to some web portals so that we can keep the password secure from people who leave the company. tasked with this i found some how-to videos about AutoIT and how flexible it is with web portals and windows GUI. So following the How to i learned how to input the username and password but my problem is i can get it to "click" on the sign in i think i can bypass that by just having it press enter after the password has been submitted but the Tech in me wants to know how I could get the program to "click" the sign in button as i am sure i am going to come across more of these in the future. Now according to the video how-to i just need to find the name of the button but when i look at the element i don't see a name and i have tried the button id, does anyone know how to accomplish this final task? #include <IE.au3> Call ("signIn") Func signIn () Global $oIE = _IECreate ("https://usercenter.checkpoint.com/usercenter/index.jsp") Local $username = _IEGetObjByName ($oIE,"username") Local $password = _IEGetObjByName ($oIE,"password") Local $button = _IEGetObjByName ($oIE,"signInUC") _IEFormElementSetValue ($username, "username_goes_here") _IEFormElementSetValue ($password, "Password_goes_here") _IEAction ($signInUC, "click") EndFunc Link to comment Share on other sites More sharing options...
Gianni Posted September 19, 2018 Share Posted September 19, 2018 (edited) Hi @MITK and welcome to the forum. ... funny, by chance I've just posted a tool that can be handy for your problem. To get a reference to elements on a web page can be easy if you have as reference a name or an ID of that element, but if that element is an "anonymous subject" placed somewhere in that "dark forest" where the DOM tree lives. well things are a bit less simple. The script I've posted in the example scripts session of the forum it has just the purpose of trying to simplify this problem. (It is here: https://www.autoitscript.com/forum/topic/195777-ie-dom-elements-visual-selector-tool/) It easily and visually finds the so called "css selector" to reference elements using the querySelector() function. Have a look to it if it can be of use for your automations. By using that tool against your site I've easily found the "selector" of the "Sign In" button, and with it your script could be modified like this for example: #include <IE.au3> Call("signIn") Func signIn() Global $oIE = _IECreate("https://usercenter.checkpoint.com/usercenter/index.jsp") Local $username = _IEGetObjByName($oIE, "username") Local $password = _IEGetObjByName($oIE, "password") Local $button = _IEGetObjByName($oIE, "signInUC") _IEFormElementSetValue($username, "username_goes_here") _IEFormElementSetValue($password, "Password_goes_here") $sSelector = "body > div:nth-of-type(2) > div > div:nth-of-type(3) > div > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr:nth-of-type(1) > td > div > div:nth-of-type(1) > form > div:nth-of-type(5) > button" $signInUC = $oIE.document.QuerySelector($sSelector) _IEAction($signInUC, "click") EndFunc ;==>signIn Edited September 19, 2018 by Chimp added welcome MITK 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
MITK Posted September 20, 2018 Author Share Posted September 20, 2018 Thank you for your assistance, works perfectly. On 9/19/2018 at 1:52 PM, Chimp said: Hi @MITK and welcome to the forum. ... funny, by chance I've just posted a tool that can be handy for your problem. To get a reference to elements on a web page can be easy if you have as reference a name or an ID of that element, but if that element is an "anonymous subject" placed somewhere in that "dark forest" where the DOM tree lives. well things are a bit less simple. The script I've posted in the example scripts session of the forum it has just the purpose of trying to simplify this problem. (It is here: https://www.autoitscript.com/forum/topic/195777-ie-dom-elements-visual-selector-tool/) It easily and visually finds the so called "css selector" to reference elements using the querySelector() function. Have a look to it if it can be of use for your automations. By using that tool against your site I've easily found the "selector" of the "Sign In" button, and with it your script could be modified like this for example: #include <IE.au3> Call("signIn") Func signIn() Global $oIE = _IECreate("https://usercenter.checkpoint.com/usercenter/index.jsp") Local $username = _IEGetObjByName($oIE, "username") Local $password = _IEGetObjByName($oIE, "password") Local $button = _IEGetObjByName($oIE, "signInUC") _IEFormElementSetValue($username, "username_goes_here") _IEFormElementSetValue($password, "Password_goes_here") $sSelector = "body > div:nth-of-type(2) > div > div:nth-of-type(3) > div > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr:nth-of-type(1) > td > div > div:nth-of-type(1) > form > div:nth-of-type(5) > button" $signInUC = $oIE.document.QuerySelector($sSelector) _IEAction($signInUC, "click") EndFunc ;==>signIn 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