Mackey Posted March 29, 2019 Posted March 29, 2019 Hi I've been trying to automate a web application. It's easier for me if the web application have object name but it doesn't have. All it had is object ID? Here's the sample script I've created. The output always shows that "Error from function _IEGetObjID, $_IESTATUS_InvalidObjectType" and so many others. I've indicated the objectID as the "loginForm" but it seems that it is an invalid object type? Might as well know where did I get wrong in here.
Moderators Melba23 Posted March 29, 2019 Moderators Posted March 29, 2019 Moved to the appropriate forum. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Nine Posted March 29, 2019 Posted March 29, 2019 Hi @Mackey, the second parameter of the _IECreate is either 0 or 1 but not 10. Should you post your code, use <> (just before emoticon) not image. If you have problem with accessing some objects in IE and the site is not publicly accessible, please post the DOM of the problematic objects (now image is best). “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Mackey Posted April 1, 2019 Author Posted April 1, 2019 Hi @Nine, thanks. I tried to do it from the scratch and tried a different web application. So here's the script I've created: #include <IE.au3> #include <Constants.au3> ;If $CmdLine[0] < 2 Then ; MsgBox($MB_OK, "Usage", "ps_OEMCC <username> <password>") ;Else ; test_login($CmdLine[1], $CmdLine[2]) ;EndIf test_login("test", "test") Func test_login ($username, $password) Local $p2is = _IECreate("https://p2is.trends.com.ph/p2is/", 1) ;Local $ie = _IEAttach("https://p2is.trends.com.ph/p2is/") If VarGetType($p2is) == "Object" Then $hwnd = _IEPropertyGet($p2is, "hwnd") WinSetState($hwnd, "", @SW_MAXIMIZE) WinWaitActive($hwnd) ;$oFrames = _IEFrameGetCollection($p2is) ;$login_form = _IEGetObjById($oFrames, "login-form") Sleep(500) Local $user_field = _IEGetObjById($p2is, "username-field") _IEFormElementSetValue = ($username_field, $username) Send("{TAB}") Local $pass_field = _IEGetObjById($p2is, "password-field") _IEFormElementSetValue = ($pass_field, $password) _IEFormSubmit($p2is, 1) WinWaitClose($hwnd) EndIf EndFunc Some lines are comment out just for testing. After I run the command, this is the output it shows: >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Apps\putangina.au3" --> IE.au3 T3.0-2 Warning from function _IEAttach, $_IESTATUS_NoMatch "C:\Apps\putangina.au3" (22) : ==> Error parsing function call.: _IEFormElementSetValue = ($username_field, $username) ^ ERROR >Exit code: 1 Time: 6.356 I just wonder why I get this kind of error when I also used this line on my other scripts and it's actually working? Also see attached DOM for your reference.
Mackey Posted April 1, 2019 Author Posted April 1, 2019 Hi @Melba23. I'm sorry. I'm new to this forum. How can I move this topic from another forum?
Nine Posted April 1, 2019 Posted April 1, 2019 (edited) @Mackey _IEFormElementSetValue is a function. So there is no = after a function. Look, at the help file for that specific function, especially the examples of it. You will notice that it usually uses the form object to access it. In your case you are trying to access it directly, but it should work too. You will have to test it. To debug your code, it is very important that you check the result after each function you are using (for @error and other status). Finally use the tool tidy (in scite) to properly indent your code, so it is easier for us to read it. ps. for username, the variable you declared is $user_field and you are using $username_field in the function... Edited April 1, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Mackey Posted April 2, 2019 Author Posted April 2, 2019 17 hours ago, Nine said: @Mackey _IEFormElementSetValue is a function. So there is no = after a function. Look, at the help file for that specific function, especially the examples of it. You will notice that it usually uses the form object to access it. In your case you are trying to access it directly, but it should work too. You will have to test it. To debug your code, it is very important that you check the result after each function you are using (for @error and other status). Finally use the tool tidy (in scite) to properly indent your code, so it is easier for us to read it. ps. for username, the variable you declared is $user_field and you are using $username_field in the function... Hi @Nine. Sorry about that. I was able to make it work on my workstation. But when I tried it on our server, I always get this error: >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\App\Monarch.au3" --> IE.au3 T3.0-2 Warning from function _IEAttach, $_IESTATUS_NoMatch --> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147417848, Browser has been deleted prior to operation.) --> IE.au3 T3.0-2 Error from function _IEPropertyGet, $_IESTATUS_InvalidObjectType It opens the web application I needed but it just stuck like that. It is not automating the credentials that needs to be input. I also tried not to close the web application and tried to execute again the script and it just suddenly work. Is it really needed do add the command _IEAttach on my script? Also, I can't find the error on my command in _IEPropertyGet. #include <Constants.au3> #include <IE.au3> If $CmdLine[0] < 2 Then MsgBox($MB_OK, "Usage", "ps_OEMCC <username> <password>") Else Monarch_login($CmdLine[1], $CmdLine[2]) EndIf Func Monarch_login($username, $password) Local $ie = _IECreate("http://mmisapp02/MSAdmin/", 1) If VarGetType($ie) == "Object" Then $hwnd = _IEPropertyGet($ie, "hwnd") WinSetState($hwnd, "", @SW_MAXIMIZE) WinWaitActive($hwnd) $user_field = _IEGetObjById($ie, "login") _IEFormElementSetValue($user_field, $username) $pass_field = _IEGetObjById($ie, "password") _IEFormElementSetValue($pass_field, $password) Send("{ENTER}") WinWaitClose($hwnd) EndIf EndFunc It's just weird that web application that I'm accessing is both intranet. The first one I automated, works. But this one won't work. DOM for reference: Many thanks, @Nine
Nine Posted April 2, 2019 Posted April 2, 2019 The error you got in _IELoadWait is in fact error 0x80010108. It comes from the _IECreate. Must be the setup of your server (protected mode maybe). Google the error 0x80010108 to find more information about it. The code is good, it is not an AutoIt problem anymore. Good luck. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Mackey Posted April 3, 2019 Author Posted April 3, 2019 15 hours ago, Nine said: The error you got in _IELoadWait is in fact error 0x80010108. It comes from the _IECreate. Must be the setup of your server (protected mode maybe). Google the error 0x80010108 to find more information about it. The code is good, it is not an AutoIt problem anymore. Good luck. Hi @Nine! Thank you for your help. Will update soon if it works. Many thanks.
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