YouriKamps Posted July 31, 2014 Share Posted July 31, 2014 Hello all, I've read a lot the couple of last weeks, learned a lot, tried a lot, but now I'm actually stuck... I have a webpage which I try to control and I already figured out that the buttons nee to be clicked using ControlSend (other methods didn't work). The page is a JSP with frames, my code does fill in the first field, but not the second and it keeps throwing the following error: --> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (GEBRUIKER1) --> IE.au3 T3.0-1 Error from function _IEAction(focus), $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (WACHTWOORD1) --> IE.au3 T3.0-1 Error from function _IEAction(focus), $_IESTATUS_InvalidDataType I started with the login page, and because of the structure of the whole website (actually a ticketing system for tech support) if this works than I can control everything. My code for testing thus far is this (removed proprietary urls, they only work on our intranet): #include <IE.au3> #RequireAdmin Global $oIE = _IECreate("link_to_application") Func ats_idaction($ats_id, $ats_action) Local $oSubmit = _IEGetObjById($oIE, $ats_id) Local $hWnd = _IEPropertyGet($oIE, "hwnd") _IEAction($oSubmit, "focus") ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $ats_action) EndFunc _IELoadWait($oIE) ats_idaction("GEBRUIKER1", "my_username") ats_idaction("WACHTWOORD1", "my_password") The html for the first (and any) field: <input id="GEBRUIKER1" class="DFGUISLE" type="TEXT" style="position: absolute; left: 400px; top: 176px; width: 78px; height: 22px; text-decoration: none; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" maxlength="8" name="GEBRUIKER1" autocomplete="off"> Tried both IEGetObjById and IEGetObjByName but now I'm just stuck... Any tips or help? Link to comment Share on other sites More sharing options...
Danp2 Posted July 31, 2014 Share Posted July 31, 2014 You mentioned that there were frames involved, but you didn't give any further details and you code doesn't make any attempt to handle them. You will need to get a reference to the desired frame (see _IEFrameGetObjByName) and then use this instead of $oIE when attempting to locate additional objects. YouriKamps 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
JohnOne Posted July 31, 2014 Share Posted July 31, 2014 Unless it's a cross domain frame. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
YouriKamps Posted July 31, 2014 Author Share Posted July 31, 2014 Ok, it's not a cross domain frame (luckily), and using _IEFrameGetObjByName I can use ControlSend to fields and buttons, but now it's throwing popups (dialogwindows) using the exact same jsp and frames. Using _IEAttach("title of window", "dialogbox") I can find the URL (it attaches to the dialogwindow, I checked the url), but using the same method of _IEFrameGetObjByName to get to the frame inside of the dialogbox for sending a ControlSend won't work... Anything special I need to do to use ControlSend to a button on the attached dialogbox with frames? I tried it in the exact same way as getting to the fields and buttons inside the first frame after finding out that the dialogbox is structured the same as the first frame. Is Local $hWnd = _IEPropertyGet($oIE, "hwnd") different for working inside a dialogbox? Link to comment Share on other sites More sharing options...
JohnOne Posted July 31, 2014 Share Posted July 31, 2014 Start by showing how you"use ControlSend to fields and buttons" in your IE page. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
YouriKamps Posted August 1, 2014 Author Share Posted August 1, 2014 (edited) Func ats_idactionpopup does attach to the correct dialogbox (I commented out the MsgBox, but this shows the correct url used in the dialogbox). The dialogbox is structured in the exact same way as the main jsp with the same name frame (AppWindow), but ControlSend doesn't send the {enter} to Button1. Console output: --> IE.au3 T3.0-1 Error from function _IEPropertyGet, $_IESTATUS_InvalidObjectType Complete code: #include <IE.au3> #include <MsgBoxConstants.au3> #RequireAdmin Global $oIE = _IECreate("url_to_webpage") Func ats_idactionmain($ats_id, $ats_action) Local $oFrame = _IEFrameGetObjByName($oIE, "AppWindow") Local $oSubmit = _IEGetObjByName($oFrame, $ats_id) Local $hWnd = _IEPropertyGet($oIE, "hwnd") _IEAction($oSubmit, "focus") ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $ats_action) EndFunc Func ats_idactionpopup($ats_popup, $ats_idpopup, $ats_actionpopup) Local $oIEpopup = _IEAttach($ats_popup, "dialogbox") ;MsgBox($MB_SYSTEMMODAL, "The URL", _IEPropertyGet($oIEpopup, "locationurl")) Local $oFramepopup = _IEFrameGetObjByName($oIEpopup, "AppWindow") Local $oSubmitpopup = _IEGetObjByName($oFramepopup, $ats_idpopup) Local $hWndpopup = _IEPropertyGet($oIEpopup, "hwnd") _IEAction($oSubmitpopup, "focus") ControlSend($hWndpopup, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $ats_actionpopup) EndFunc _IELoadWait($oIE) ats_idactionmain("GEBRUIKER1", "username") ats_idactionmain("WACHTWOORD1", "password") ats_idactionmain("Pb_inloggen", "{enter}") Sleep(4000) ats_idactionpopup("afdelingskeuze", "Button1", "{enter}") EDIT: It is driving me nuts... Using the following I found out for sure that it is attaching to the correct dialogbox: Local $oFrames = _IEFrameGetCollection($oIEpopup) Local $iNumFrames = @extended Local $sTxt = $iNumFrames & " frames found" & @CRLF & @CRLF Local $oFramepopup = 0 For $i = 0 To ($iNumFrames - 1) $oFramepopup = _IEFrameGetCollection($oIEpopup, $i) $sTxt &= _IEPropertyGet($oFramepopup, "innertext") & @CRLF Next MsgBox($MB_SYSTEMMODAL, "Frames Info", $sTxt) It even gives me the text in the correct frame (name AppWindow). Switched to debug-output and found the line it chokes on: 0047: 0-0: ats_idactionpopup("afdelingskeuze", "Button1", "{enter}") 0017: 0-0: Local $oIEpopup = _IEAttach($ats_popup, "dialogbox") 0018: 0-0: Local $oFramepopup = _IEFrameGetObjByName($oIEpopup, "AppWindow") 0019: 0-0: Local $oSubmitpopup = _IEGetObjByName($oIEpopup, $ats_idpopup) --> IE.au3 T3.0-1 Warning from function _IEGetObjByName, $_IESTATUS_NoMatch (Name: Button1, Index: 0) 0020: 7-0: Local $hWndpopup = _IEPropertyGet($oFramepopup, "hwnd") --> IE.au3 T3.0-1 Error from function _IEPropertyGet, $_IESTATUS_InvalidObjectType 0021: 4-1: _IEAction($oSubmitpopup, "focus") --> IE.au3 T3.0-1 Error from function _IEAction(focus), $_IESTATUS_InvalidDataType 0022: 3-1: ControlSend($hWndpopup, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $ats_actionpopup) 0023: 0-0: EndFunc but when looking at the source, using debugbar AND firebug, this should be the correct button... Since the dialogbox and the main window have the exact same html (it just loads a different .html in a frame with the same name as the main frame in the main window) I figured I could use almost the same code (but with the addition of Local $oIEpopup = _IEAttach($ats_popup, "dialogbox")). Does _IEGetObjByName behave differently inside a dialogbox perhaps? Edited August 1, 2014 by YouriKamps Link to comment Share on other sites More sharing options...
Solution YouriKamps Posted August 1, 2014 Author Solution Share Posted August 1, 2014 Ok, I found a way around the problem. The problem was getting a non-existing hwnd, so instead of Local $hWndpopup = _IEPropertyGet($oIEpopup, "hwnd") I used WinGetHandle. i will mark this as solved 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