SkellySoul Posted March 12, 2014 Share Posted March 12, 2014 (edited) Hey everyone. I am working on something new and have ran into afew problems This code works believe it or not lol $oIE = _IECreate($Info_Link[0], 0, 1, 1, 0) $Info_Login_Form = _IEFormGetCollection($oIE, 0) $Info_Login_Address = _IEFormElementGetCollection($Info_Login_Form, 0) _IEFormElementSetValue($Info_Login_Address, $Info_Account[1]) $Info_Login_Password = _IEFormElementGetCollection($Info_Login_Form, 1) _IEFormElementSetValue($Info_Login_Password, $Info_Account[2]) _IEFormSubmit($Info_Login_Form, 0) ; Change later!!! _IELoadWait($oIE) ; Change later!!! $Log_Attempt += 1 The issue is when I do this instead $oIE = _IECreate($Info_Link[100], 0, 1, 1, 0) ; This is an example of me using IE create for a different page ;;;;;;;;; ; We do stuff here...Nothing that should interfere with the bottom code... ;;;;;;;;; _IENavigate($oIE, $Info_Link[1]) ; We use this instead to enter information ; _IELoadWait($oIE) I have tried playing with this but still nothing... $Info_Login_Form = _IEFormGetCollection($oIE, 0) $Info_Login_Address = _IEFormElementGetCollection($Info_Login_Form, 0) _IEFormElementSetValue($Info_Login_Address, $Info_Account[1]) $Info_Login_Password = _IEFormElementGetCollection($Info_Login_Form, 1) _IEFormElementSetValue($Info_Login_Password, $Info_Account[2]) _IEFormSubmit($Info_Login_Form, 0) ; Change later!!! _IELoadWait($oIE) ; Change later!!! $Log_Attempt += 1 In the helpfile it says the following New security in Windows Vista causes a new browser window to be created when a browser is instructed to navigate to a URL in a different security zone. This occurs as well with the initial creation and navigation initiated with _IECreate(). The new window is a new browser instance and the previous browser object variable no longer points to it. There are several workarounds: 1) add #RequireAdmin to your code (this is required even if the account is part of the Administrator's Group and will prompt for credentials if necessary), 2) use _IEAttach() to connect to the new browser window 3) add the target website to the Trusted Sites security zone in IE, 4) turn off "Protected Mode" in IE, or 5) disable UAC. Care must be taken to understand the implications of disabling IE security features when accessing untrusted sites. I have added RequireAdmin to my script I have turned off "Protected Mode" in IE (I use Chrome + Firefox, so I am not too concerned) I have NOT disabled UAC or added the site it's self as a trusted site in the security zone because I feel the problem is with the script. So what happens?...well when I use the first posted code it logins just fine....when I use the second example...it doesn't enter the information...almost as if it is hanging somewhere... Unrelated issue: Even though the first code does work I have to do this in order for the script to continue _IEFormSubmit($Info_Login_Form, 0) ; Change later!!! _IELoadWait($oIE) ; Change later!!! instead of just doing this...if I do it pauses the script... _IEFormSubmit($Info_Login_Form) So what exactly is going on with IE and how do I fix these issues. I noticed im not the only one who has ran into these types of problems Thanks! Edited March 12, 2014 by SkellySoul Link to comment Share on other sites More sharing options...
Danp2 Posted March 12, 2014 Share Posted March 12, 2014 Have you tried using _IEAttach() after the call to _IENavigate() so that you have a reference to the correct browser object? So what happens?...well when I use the first posted code it logins just fine....when I use the second example...it doesn't enter the information...almost as if it is hanging somewhere... Run the code in Scite and check the results in the Output window. This should help identify which command is initially failing. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
SkellySoul Posted March 12, 2014 Author Share Posted March 12, 2014 (edited) would this work _IEAttach($oIE) because , I don't like relying on string names. (especially considering I have quite a few links involved.) [edit] It does seem like a good idea..., if it works, and well it is appreciated, it seems like more of a hotfix than getting at the root of the actual problem. [edit] Sctie returns no errors for either code...just it pauses the script/hangs or doesn't attach/focus properly. Edited March 12, 2014 by SkellySoul Link to comment Share on other sites More sharing options...
Danp2 Posted March 12, 2014 Share Posted March 12, 2014 Have you tried this?: _IENavigate($oIE, $Info_Link[1]) $oIE = _IEAttach($Info_Link[1], 'url') $Info_Login_Address = _IEFormElementGetCollection($Info_Login_Form, 0) _IEFormElementSetValue($Info_Login_Address, $Info_Account[1]) $Info_Login_Password = _IEFormElementGetCollection($Info_Login_Form, 1) _IEFormElementSetValue($Info_Login_Password, $Info_Account[2]) _IEFormSubmit($Info_Login_Form, 0) ; Change later!!! _IELoadWait($oIE) ; Change later!!! $Log_Attempt += 1 Do you get *any* output in the Scite Output window? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
SkellySoul Posted March 12, 2014 Author Share Posted March 12, 2014 (edited) I tried this expandcollapse popup#include <IE.au3> #include <Misc.au3> #include <Array.au3> #include <String.au3> Global $oIE, $Link[10], $Account[10], $Log_Attempt = 1, $Max_Attempt = 5 _Singleton(@ScriptName) ; just incase $Account[0] = "Test" ; Username $Account[1] = "Test@gmail.com" ; Email $Account[2] = "123" ; Password $Link[0] = "https://www.google.com/auth?zone=6" ; Login Link $Link[1] = "http://www.google.com/index.php?cmd=" ; Main Link $oIE = _IECreate($Link[1] & "profile", 0, 1, 1, 0) ; We can use the $Array & X to reach destination (Example: $Link[1] & "profile") _Login() Func _Login() $Info = _IEDocReadHTML($oIE) $User_Name = _StringBetween($Info, 'id="statbar-account">', '</dt>') If Not @Error And $User_Name[0] == $Account[0] Then ConsoleWrite(@CRLF & "+ We are in!" & @CRLF) Elseif $Log_Attempt == $Max_Attempt Then MsgBox(0, "", "Exit Script - Failed Attempts") _IEQuit($oIE) Exit Else ConsoleWrite(@CRLF & "- Attempting to login" & @CRLF) ;We quit $oIE and make a new handle because _IENavigate() hangs... ;_IENavigate($oIE, $Link[0]) _IEQuit($oIE) ; Replace with _IENav $oIE = _IECreate($Link[0], 0, 1, 1, 0) ; Replace with _IENav ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $Login_Form = _IEFormGetCollection($oIE, 0) $Login_Address = _IEFormElementGetCollection($Login_Form, 0) _IEFormElementSetValue($Login_Address, $Account[1]) $Login_Password = _IEFormElementGetCollection($Login_Form, 1) _IEFormElementSetValue($Login_Password, $Account[2]) _IEFormSubmit($Login_Form, 0) ; Change later!!! _IELoadWait($oIE) ; Change later!!! $Log_Attempt += 1 _IENavigate($oIE, $Link[1] & "profile") _Login() EndIf EndFunc I then tried your example expandcollapse popup#include <IE.au3> #include <Misc.au3> #include <Array.au3> #include <String.au3> Global $oIE, $Link[10], $Account[10], $Log_Attempt = 1, $Max_Attempt = 5 _Singleton(@ScriptName) ; just incase $Account[0] = "Test" ; Username $Account[1] = "Test@gmail.com" ; Email $Account[2] = "123" ; Password $Link[0] = "https://www.google.com/auth?zone=6" ; Login Link $Link[1] = "http://www.google.com/index.php?cmd=" ; Main Link $oIE = _IECreate($Link[1] & "profile", 0, 1, 1, 0) _Login() Func _Login() $Info = _IEDocReadHTML($oIE) $User_Name = _StringBetween($Info, 'id="statbar-account">', '</dt>') If Not @Error And $User_Name[0] == $Account[0] Then ConsoleWrite(@CRLF & "+ We are in!" & @CRLF) ElseIf $Log_Attempt == $Max_Attempt Then MsgBox(0, "", "Exit Script - Failed Attempts") _IEQuit($oIE) Exit Else ConsoleWrite(@CRLF & "- Attempting to login" & @CRLF) _IENavigate($oIE, $Link[0]) $oIE = _IEAttach($Link[0], 'url') _IELoadWait($oIE) $Login_Form = _IEFormGetCollection($oIE, 0) $Login_Address = _IEFormElementGetCollection($Login_Form, 0) _IEFormElementSetValue($Login_Address, $Account[1]) $Login_Password = _IEFormElementGetCollection($Login_Form, 1) _IEFormElementSetValue($Login_Password, $Account[2]) _IEFormSubmit($Login_Form, 0) ; Change later!!! _IELoadWait($oIE) ; Change later!!! $Log_Attempt += 1 _IENavigate($oIE, $Link[1] & "profile") _Login() EndIf EndFunc both don't work properly...(these are also just examples of my code) If I login manually run the script it says "We are in!" and I can continue...If I logout of the site manually, run the script, it logins properly...but when it loops back to check if we are in, it just sits there idling [edit] Scite returns no errors in my code. Edited March 12, 2014 by SkellySoul Link to comment Share on other sites More sharing options...
Danp2 Posted March 12, 2014 Share Posted March 12, 2014 I get a 404 error (page not found) when running your scripts. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
SkellySoul Posted March 13, 2014 Author Share Posted March 13, 2014 They are just examples...the links arent the real links I use. Link to comment Share on other sites More sharing options...
Danp2 Posted March 13, 2014 Share Posted March 13, 2014 Understood... but if you are going to post code to demonstrate the issue, the code should be functional. Latest Webdriver UDF Release Webdriver Wiki FAQs 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