Suki Posted February 24, 2017 Share Posted February 24, 2017 Hi, I am not able to clock the submit button , text enclosed in black box in attachment. This has no name or id. While trying to solve this I saw that I was unable to get the form name (loginform) as well. Code for form fetch: Local $oForms = _IEFormGetCollection($oIE) Local $iNumForms = @extended MsgBox($MB_SYSTEMMODAL, "Forms Info", "There are " & $iNumForms & " forms on this page") Local $oForm For $i = 0 To $iNumForms - 1 $oForm = _IEFormGetCollection($oIE,1) MsgBox($MB_SYSTEMMODAL, "Form Info", $oForm.name) Next This shows me the number of forms correctly, ref. first message box but when it enters the for loop it does not print any form name under $oForm.name Code to click on the submit button : local $oTDs = $oIE.document.GetElementsByTagName($oIE, "input") For $oTD in $oTDs If String(_IEPropertyGet($oTD, "innertext")) = "Sign in " Then Send("{Enter}") ExitLoop EndIf Next Nothing happens PS - IF I JUST DO A SEND the website throws an error message stating invalid username or password. Link to comment Share on other sites More sharing options...
Subz Posted February 25, 2017 Share Posted February 25, 2017 Try: Local $oButtons = _IETagNameGetCollection($oIE, "Input") For $oButton In $oButtons If $oButton.value = 'Sign in' Then MsgBox(64, 'Button Found', 'Button found with value: ' & $oButton.value) _IEAction($oButton, 'click') Next Link to comment Share on other sites More sharing options...
Suki Posted February 25, 2017 Author Share Posted February 25, 2017 Hi Subz thanks this works but i am facing the same issue as earlier. When i just did a send<enter> earier (and now i click on the button) the website throws an error invalid username or password. Is this related to the website security? If so , how to get around this? This is an intranet site so i can change the security settings if needed... Link to comment Share on other sites More sharing options...
Subz Posted February 25, 2017 Share Posted February 25, 2017 Are you 100% sure the username and password are correct? I'm assuming you're sending this information to the form? Can you please confirm and if yes can you post an example of the code? Link to comment Share on other sites More sharing options...
Suki Posted February 25, 2017 Author Share Posted February 25, 2017 Call ("login") func login () #RequireAdmin Global $oIE=_IECreate("http://localhost:8001/en-US/") Local $username=_IEGetObjByName($oIE,"username") local $password=_IEGetObjByName($oIE,"password") _IEFormElementSetValue($username,"admin") sleep (30000) Send("{TAB}") _IEFormElementSetValue($password,"Stalin1945") sleep (30000) send ("{TAB}") Local $oButtons = _IETagNameGetCollection($oIE, "Input") For $oButton In $oButtons If $oButton.value = 'Sign in' Then MsgBox(64, 'Button Found', 'Button found with value: ' & $oButton.value) ;_IEAction($oButton, 'click') Next I could log in to several other websites and also do operations inside the website but this one always gives the same issues see attached screen shot as well for some reason it is going inside the account log in error class Link to comment Share on other sites More sharing options...
Subz Posted February 25, 2017 Share Posted February 25, 2017 Can you try: #include <IE.au3> Local $oIE = _IECreate("http://localhost:8001/en-US/", 1) While _IEPropertyGet($oIE, "Busy") Sleep(100) WEnd Local $oForm = _IEFormGetObjByName($oIE, "loginForm") Local $oUserName = _IEFormElementGetObjByName($oForm, "UserName") _IEFormElementSetValue($oUserName, "Domain\UserName") Local $oPassword = _IEFormElementGetObjByName($oForm, "Password") _IEFormElementSetValue($oPassword, "Password") _IEFormSubmit($oForm) Link to comment Share on other sites More sharing options...
Danp2 Posted February 25, 2017 Share Posted February 25, 2017 17 hours ago, Suki said: While trying to solve this I saw that I was unable to get the form name (loginform) as well. This section of code is wrong -- For $i = 0 To $iNumForms - 1 $oForm = _IEFormGetCollection($oIE,1) MsgBox($MB_SYSTEMMODAL, "Form Info", $oForm.name) Next The call to _IEFormGetCollection should be using $i, not a constant of 1. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Suki Posted February 26, 2017 Author Share Posted February 26, 2017 @subz - no , not working. @dan0 - Yes you are right, I was testing and made a mistake, anyway no reason this should not return any value. there are 2 forms on this page , putting $i should return both the forms in the for loop or putting 0 or 1 should return the first and second form names respectively, This while code on fetching form names from auto it does not work, see example from the autoit help menu Local $oIE = _IECreate("http://www.autoitscript.com") Local $oForms = _IEFormGetCollection($oIE) MsgBox($MB_SYSTEMMODAL, "Forms Info", "There are " & @extended & " form(s) on this page") For $oForm In $oForms MsgBox($MB_SYSTEMMODAL, "Form Info", $oForm.name) Next This should return the form name on autoitscript.com page , right? well it does not, attaching screen shot form name is always blank. If the autoit example code on the autoitscript page is failing what hope do I have :)? Link to comment Share on other sites More sharing options...
Danp2 Posted February 26, 2017 Share Posted February 26, 2017 If you check the source, the form has no defined name. ;-) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Subz Posted February 26, 2017 Share Posted February 26, 2017 (edited) Can you try: #include <IE.au3> Local $oIE = _IECreate("http://localhost:8001/en-US/", 1) While _IEPropertyGet($oIE, "Busy") Sleep(100) WEnd Local $bForm = False Local $oForms = _IETagNameGetCollection($oIE, "form") Local $oInputs = _IETagNameGetCollection($oIE, "input") For $oForm In $oForms If $bForm = True Then Exitloop If $oForm.ClassName = "loginForm" Then For $oInput In $oInputs If $oInput.GetAttribute("Data-Name") = "username" Then $oInput.value = "admin" If $oInput.GetAttribute("Data-Name") = "password" Then $oInput.value = "Stalin1945" If $oInput.value = 'Sign in' Then MsgBox(64, 'Input Found', 'Input found with value: ' & $oInput.value) _IEAction($oInput, 'click') $bForm = True Exitloop EndIf Next EndIf Next Edited February 26, 2017 by Subz Added $bForm Link to comment Share on other sites More sharing options...
jdelaney Posted February 28, 2017 Share Posted February 28, 2017 (edited) Many login pages now require a send to 'validate' the data (example...you set the value, but the button doesn't enable until you actually send a character at user/password inputs)...So doing a focus action, and then controlsend at the browser will fill in the data. You can also look at my sig to grab elements by xpath. Edited February 28, 2017 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Suki Posted March 4, 2017 Author Share Posted March 4, 2017 ha well..i had a discussion on this particular thing with my web developer. There is a setting which detects insecure logins in the web config file, that had to be turned off..after that it works.many thanks for helping me out. I am not sure though how I will manage to run it for multiple users , currently I am in discussion with the users to either turn off the insecure log in settings or have a manual log in. There are operations inside the url that is more important to automate and I am working on that, Once again many thanks to Dan, Subz and jdelaney Link to comment Share on other sites More sharing options...
luny Posted March 13, 2017 Share Posted March 13, 2017 how did you turn off the insecure login plz,, 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