blackeaglemn Posted January 25, 2015 Share Posted January 25, 2015 (edited) Hello all, i am trying to automate my login to 2 different websites.. the first function works well however i cannot make the other function to work since the IE is not entering username/pas or clicking or accessing anything in the new TAB.. so please help me fix the script to make the new tab enter the login info and signs in just like the first tab!( please note that both function works however only the 1st one is in action) #include <IE.au3> Call ("website1") Func website1() Global $oIE = _IECreate ("http://www.website1.com") Local $username = _IEGetObjByName ($oIE,"username") Local $password = _IEGetObjByName ($oIE,"password") _IEFormElementSetValue ($username,"URusername") _IEFormElementSetValue ($password,"URpassword") $inputs = $oIE.document.getElementsByTagName("input") For $input In $inputs $input.click() EndFunc Edited January 26, 2015 by blackeaglemn Link to comment Share on other sites More sharing options...
Danp2 Posted January 25, 2015 Share Posted January 25, 2015 $oIE continues to point to the original tab even after you create the new one. You will need to _IEAttach to the new tab and use the returned object to interact with it. On a separate issue, have you tried using _IEFormSubmit instead of looping though each of the input elements? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
blackeaglemn Posted January 25, 2015 Author Share Posted January 25, 2015 $oIE continues to point to the original tab even after you create the new one. You will need to _IEAttach to the new tab and use the returned object to interact with it. On a separate issue, have you tried using _IEFormSubmit instead of looping though each of the input elements? hello sir,thanks for ur reply sir i added this line : $oIE = _IEAttach("https://website2.com") just belolw the navigate2("https://website2.com) but it didnt work and i get this Warning from function _IEAttach, $_IESTATUS_NoMatch --> IE.au3 T3.0-1 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType ".......eah.au3" (35) : ==> Variable must be of type "Object".: $inputs = $oIE.document.getElementsByTagName("input") $inputs = $oIE^ ERROR >Exit code: 1 ---- regarding the IEFormSubmit, i read about it but didnt know how to use it.. so as far as this loop is working i dont mind it... but how to make IEAttach work? Link to comment Share on other sites More sharing options...
pcjunki Posted January 25, 2015 Share Posted January 25, 2015 why are you using global for website1? Link to comment Share on other sites More sharing options...
blackeaglemn Posted January 25, 2015 Author Share Posted January 25, 2015 why are you using global for website1? Am new to this, but i;ve used the global $oIE because i want to use it in the other function, i dont want to create new IE, i want the same IE but new tab inside it.. Link to comment Share on other sites More sharing options...
pcjunki Posted January 25, 2015 Share Posted January 25, 2015 have you double checked the element names on the website(s), you sure they are named "input"? Link to comment Share on other sites More sharing options...
blackeaglemn Posted January 25, 2015 Author Share Posted January 25, 2015 have you double checked the element names on the website(s), you sure they are named "input"? yes sir, the code and website of func 2 works well if i switch it with the first function, so i guess as stated before it needs to be attached to the new tab but i am not knowing how to use IEattach to make it work Link to comment Share on other sites More sharing options...
pcjunki Posted January 25, 2015 Share Posted January 25, 2015 somewhere in func2 we need to get a handle on website1 and attach to it I have code at work, but no access to it now, and I have yard work to do look up wingethandle for the 2nd function then do the attaching https://www.autoitscript.com/autoit3/docs/functions/WinGetHandle.htm Link to comment Share on other sites More sharing options...
blackeaglemn Posted January 25, 2015 Author Share Posted January 25, 2015 somewhere in func2 we need to get a handle on website1 and attach to it I have code at work, but no access to it now, and I have yard work to do look up wingethandle for the 2nd function then do the attaching https://www.autoitscript.com/autoit3/docs/functions/WinGetHandle.htm $oIE =_IEAttach(WinGetHandle("website2.com"),"HWnd") $oIE =_IEAttach(WinGetHandle("website2.com"),"embedded") i've tried attaching using the one of the above methods...its getting attached but am getting errors afters attaching seems i cant get object after attaching: Warning from function _IEAttach, $_IESTATUS_NoMatch --> IE.au3 T3.0-1 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType "------eah.au3" (39) : ==> Variable must be of type "Object".: $inputs = $oIE.document.getElementsByTagName("input") $inputs = $oIE^ ERROR >Exit code: 1 ---- please note am designing it for multiple site logins not only 2, so there might also be other functions added or else i would have managed to make the script run on the same ie tab one after the other... but with several logins it will take time.. thanks Link to comment Share on other sites More sharing options...
Danp2 Posted January 25, 2015 Share Posted January 25, 2015 i added this line : $oIE = _IEAttach("https://website2.com") just belolw the navigate2("https://website2.com) If you read the help file entry for _IEAttach, you will see that the default mode is "title". For your code to work, you would need to pass the 2nd parameter as well: $oIE = _IEAttach("https://website2.com", "url") Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
blackeaglemn Posted January 25, 2015 Author Share Posted January 25, 2015 If you read the help file entry for _IEAttach, you will see that the default mode is "title". For your code to work, you would need to pass the 2nd parameter as well: $oIE = _IEAttach("https://website2.com", "url") Sir , beleive me i've tried all things in help regarding IEattach , its either impossible to get and set object after attaching to or i should use something that enables the get and set objects ... again this is the error i get.. unless someone goes through it and tries the script on there pc then its my pc or IE v11 fault IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch --> IE.au3 T3.0-1 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType "-----ceah.au3" (38) : ==> Variable must be of type "Object".: $inputs = $oIE.document.getElementsByTagName("input") $inputs = $oIE^ ERROR >Exit code: 1 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 25, 2015 Moderators Share Posted January 25, 2015 (edited) There are tab attach/create functions and examples here '?do=embed' frameborder='0' data-embedContent>> Also a WinGetBrowserObjArray that returns all the browser objects (new IE's or tabs) based on your criteria. Edited January 25, 2015 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Solution Danp2 Posted January 25, 2015 Solution Share Posted January 25, 2015 It looks like the _IEAttach is occurring too quickly. You may want to review >this thread for some ideas on how to address this issue. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
blackeaglemn Posted January 25, 2015 Author Share Posted January 25, 2015 thanks for your replies... i did solve the problem and its attached on the next tab but after getting several warning until its been attached look i added this while loop While 1 $oIE = _IEAttach("website2 title") If IsObj($oIE) Then ExitLoop WEND warning is as follows ........ ..... ..... ..... ....( several warning - IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch) ........ .. ... .. .... .... .. --> IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch --> IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch >Exit code: 0 Time: 17.23 then after its looping for some time until its been attached it exists the loop and since its an object now everything runs correctly i woudnt mind anything better than this code.. but for now it works perfectly.. thanks again Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 25, 2015 Moderators Share Posted January 25, 2015 While Danp2's link leads to something I wrote, I have a much better/solid solution provided in the link I provided above. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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