Jump to content

Recommended Posts

Posted

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.

image.png.3be30b0de103b6d4a89d4b94032d0d0c.png

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
Posted

Moved to the appropriate forum.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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). 

Posted

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.

image.png.b1f702c6b0cf7e3105661b4ea01c3a11.png

Posted (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 by Nine
Posted
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:

image.png.4c0ef3d32091747e7ae232c28658ec95.png

Many thanks, @Nine

Posted

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.

Posted
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. 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...