Ganesh2VL Posted November 30, 2016 Share Posted November 30, 2016 (edited) Dear All, I am trying to login to website using AutoIT script but its failed, throwing the below error msg. "Return SetError($_IESTATUS_Success, 0, $oObject.document)" "Error: The requested action with this object has failed" Please check my below code: Func MyFunc() Local $sUsername = "***" Local $sPassword = "***" $sUrl = "http://appName:8005/OA_HTML/RF.jsp" $oIE = _IECreate($sUrl, 0, 1, 0, 1) Sleep(2000) $oHWND = _IEPropertyGet($oIE, "hwnd") WinSetState($oHWND, "", @SW_MAXIMIZE) $oForm = _IEFormGetCollection($oIE, 0) $oUsername = _IEFormElementGetObjByName($oForm, 'unamebean') ; change name ! $oPassword = _IEFormElementGetObjByName($oForm, "pwdbean") ; change name ! _IEFormElementSetValue($oUsername, $sUsername) _IEFormElementSetValue($oPassword, $sPassword) ; This is my custom defined error handler _IEFormSubmit($oForm) EndFunc Please advise why the above failed, what is the cause of this issue. If possible, share with me a working example. Edited November 30, 2016 by Ganesh2VL Link to comment Share on other sites More sharing options...
aa2zz6 Posted November 30, 2016 Share Posted November 30, 2016 Sorry, I don't have time to test yours but I'll post a working script below that I've used in the past. Revise the ID name and password accordingly and let us know if you have any questions. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <GDIPlus.au3> ;#Escape program HotKeySet("{ESC}", "Terminate") Local $iWidthCell = 70 ;#GUI Create $width = 800 ;#GUI Create $height = 625 ;#GUI Create Global $x ;#Func Email Global $y ;#Func Password _IEErrorHandlerRegister() #Region ### START Koda GUI section ### Form= $hMain = GUICreate("Test", 1015, 585, @DesktopWidth / 2 - $width / 2, @DesktopHeight / 2 - $height / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $wPos = WinGetPos($hMain) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;#Input Email GUICtrlCreateLabel("Email:", 880, 65, $iWidthCell) $hInput1 = GUICtrlCreateInput("", 880, 90, 85, 20) ;#Input Password GUICtrlCreateLabel("Password:", 880, 115, $iWidthCell) $hInput2 = GUICtrlCreateInput("", 880, 140, 85, 20) ;#Initializes the IE Explore Local $RunProgram = GUICtrlCreateButton("Run Program", 880, 170, 85, 25) ;#IE Create Func internet() Local $oIE = _IECreateEmbedded() GUICtrlCreateObj($oIE, 0, 0, $width + 0, $height + 0) _IENavigate($oIE, "https://www.facebook.com/?_rdr=p") Local $username = _IEGetObjByName($oIE, "email") Local $password = _IEGetObjByName($oIE, "pass") Local $button = _IEGetObjByName($oIE, "u_0_x") _IEFormElementSetValue($username, $x) _IEFormElementSetValue($password, $y) ;$oBtn = _IEGetObjById($oIE, "u_0_x") ; works on the main login page ;$oBtn = _IEGetObjById($oIE, "u_0_2") ; works on the second login page ; _IEAction($oBtn, "click") EndFunc ;==>internet While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $idClose ExitLoop Case $RunProgram $x = GUICtrlRead($hInput1) $y = GUICtrlRead($hInput2) internet() EndSwitch WEnd Func Email($x) $x = ControlGetText(WinGetTitle("[AutoIt v3 GUI]"), "", "[CLASS:Edit; INSTANCE:1]") EndFunc ;==>Email Func Password($y) $y = ControlGetText(WinGetTitle("[AutoIt v3 GUI]"), "", "[CLASS:Edit; INSTANCE:2]") EndFunc ;==>Password Func Terminate() Exit EndFunc ;==>Terminate Ganesh2VL 1 Link to comment Share on other sites More sharing options...
Danp2 Posted November 30, 2016 Share Posted November 30, 2016 Does the error occur if you change _IEFormSubmit to no wait for the page to load? _IEFormSubmit($oForm, 0) Also, have you tried changing the initial URL to use HTTPS instead of HTTP? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 30, 2016 Moderators Share Posted November 30, 2016 Moved to the appropriate forum. "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...
Ganesh2VL Posted December 15, 2016 Author Share Posted December 15, 2016 Thanks aa2zz6, your code works like a charm. 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