jwei Posted August 1, 2007 Share Posted August 1, 2007 I'm usting AutoIt (with IE.au3) to automate web test. The web page I'm testing has an input of type "file", by performing a click on it, a "Choose file" window will show up; and it seems that my script will be blocked at this point till the "Choose file" window disappears by some manual input. I tried WinWaitActive to wait for the "Choose file" window right after the click, but failed. What I want is to let the script finish the inputs in "Choose file" window. Anyone would like to provide a solution for this situation? Thanks! Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 1, 2007 Share Posted August 1, 2007 The script is actually waiting for the COM object which is waiting for user input. You might try setting it with text directly instead of using the click method. Link to comment Share on other sites More sharing options...
mikehunt114 Posted August 1, 2007 Share Posted August 1, 2007 (edited) ; *******************************************************; Example 5 - Set the value of an INPUT TYPE=FILE element; Same as previous example, but with invisible window; (security restrictions prevent using _IEFormElementSetValue); *******************************************************;#include <IE.au3>$oIE = _IE_Example("form"); Hide the browser window to demonstrate sending text to invisible window_IEAction($oIE, "invisible")$oForm = _IEFormGetObjByName($oIE, "ExampleForm")$oInputFile = _IEFormElementGetObjByName($oForm, "fileExample"); Assign input focus to the field and then send the text string_IEAction($oInputFile, "focus")$hIE = _IEPropertyGet($oIE, "hwnd")ControlSend($hIE, "", "Internet Explorer_Server1", "C:\myfile.txt")MsgBox(0, "Success", "Value set to C:\myfile.txt")_IEAction($oIE, "visible") Edited August 1, 2007 by mikehunt114 IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font] Link to comment Share on other sites More sharing options...
jwei Posted August 2, 2007 Author Share Posted August 2, 2007 Thanks for your reply! I tried the example but failed because ControlSend will return 0 indicating a failure. $oInputFile = _IEFormElementGetObjByName($oForm, "fileExample") ; Assign input focus to the field and then send the text string _IEAction($oInputFile, "focus") $hIE = _IEPropertyGet($oIE, "hwnd") ControlSend($hIE, "", "Internet Explorer_Server1", "C:\myfile.txt") In fact I also tried _IEFormElementSetValue, failed too $oInputFile = _IEFormElementGetObjByName($oForm, "fileExample") _IEFormElementSetValue($oInputFile, "C:\myfile.txt") Here _IEFormElementSetValue will lead to an error: "--> IE.au3 Error from function _IEFormElementSetValue, $_IEStatus_InvalidObjectType (Browser securuty prevents SetValue of TYPE=FILE)" Any ideas? Thanks! 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