SlowCoder74 Posted December 3, 2013 Posted December 3, 2013 I need to be able to auto-fill a form on a dynamic web page. Depending on data entered, some fields may become enabled/or disabled. Due to this, it is not a simple case of tabbing around a specific number of times to traverse the fields. Is there a way to bring a specific field/element into focus based on its ID? I am currently using Chrome to access the page, but if required, may be able to use IE.
Danp2 Posted December 3, 2013 Posted December 3, 2013 There are UDFs available for IE, FF, and Chrome. Have you looked into using one of those to interact with the website? Latest Webdriver UDF Release Webdriver Wiki FAQs
SlowCoder74 Posted December 3, 2013 Author Posted December 3, 2013 There are UDFs available for IE, FF, and Chrome. Have you looked into using one of those to interact with the website? Yes, I just found them. I'm goofing with the IE one at this moment.
JohnOne Posted December 3, 2013 Posted December 3, 2013 _IEAction($oIe, "focus"); Help file AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
SlowCoder74 Posted December 4, 2013 Author Posted December 4, 2013 After playing around, I'm having a terrible time just getting the code to attach to the proper IE instance. I've created a sample HTML page: <html> <head><title>Test HTML</title></head> <body> <form name="testform"> <input type="radio" name="myradios" id="thisone"> click me!<br> <input type="radio" name="myradios" id="notthisone"> don't click me!<br> </form> </body> </html> My AU3 code: #include <IE.au3> $IEhWnd = WinGetHandle("Test HTML","") $oIE = _IEAttach($IEhWnd,"HWND") ;get IE instance via hWnd ;$oIE = _IEAttach("Test HTML","WindowTitle") ;get IE instance via window title ConsoleWrite("$oIE=" & $oIE & ", Error=" & @error & @crlf) $oForm = _IEFormGetObjByName($oIE, "testform") ;get form instance ConsoleWrite("$oForm=" & $oForm & ", Error=" & @error & @crlf) _IEFormElementRadioSelect($oForm, "myradios", "thisone") ;select the radio In this project, the IE window will already be open. My SCiTE console output when executed, attaching via the IE window's handle: $oIE=, Error=0 --> IE.au3 V2.4-0 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch $oForm=0, Error=7 --> IE.au3 V2.4-0 Error from function _IEFormElementRadioSelect, $_IEStatus_InvalidDataType My SciTE console output when attempting to attach via the window title: $oIE=, Error=0 $oForm=, Error=0 --> IE.au3 V2.4-0 Warning from function _IEFormElementRadioSelect, $_IEStatus_NoMatch In either instance, why are there no (visible) values assigned to the $oIE or $oForm variables? I'm assuming something is getting assigned, because in the "WindowTitle" version, there is no error when retrieving the $oForm.
Danp2 Posted December 5, 2013 Posted December 5, 2013 Not sure that it matters... shouldn't the radio elements have values rather than ids? Latest Webdriver UDF Release Webdriver Wiki FAQs
JohnOne Posted December 5, 2013 Posted December 5, 2013 why are there no (visible) values assigned to the $oIE or $oForm variables? They are of type "object", I doubt they have a printable value. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
SlowCoder74 Posted December 5, 2013 Author Posted December 5, 2013 Not sure that it matters... shouldn't the radio elements have values rather than ids? I tried it with value= instead of id=, and it made no difference. They are of type "object", I doubt they have a printable value. Understood.
Solution bogQ Posted December 5, 2013 Solution Posted December 5, 2013 (edited) no problems here #include <IE.au3> $IEhWnd = WinGetHandle("Test HTML","") $oIE = _IEAttach($IEhWnd,"HWND") $oForm = _IEFormGetObjByName($oIE, "testform") _IEFormElementRadioSelect($oForm, "thisone", "myradios");note the diffrance from your code :P <html> <head><title>Test HTML</title></head> <body> <form name="testform"> <input type="radio" name="myradios" value="thisone"> click me!<br> <input type="radio" name="myradios" value="notthisone"> don't click me!<br> </form> </body> </html> Edited December 5, 2013 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
Danp2 Posted December 5, 2013 Posted December 5, 2013 _IEFormElementRadioSelect($oForm, "thisone", "myradios");note the diffrance from your code LOL. Good catch! Latest Webdriver UDF Release Webdriver Wiki FAQs
SlowCoder74 Posted December 5, 2013 Author Posted December 5, 2013 Ok, there were 2 problems with my code, then. I didn't understand that it was looking for the value of the element. And based on that lack of understanding, I was misinterpreting the parameters of the _IEFormElementRadioSelect command. Thank you, everyone, for your help!
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