Jump to content

Cannot interact with Choose File to Upload IE8

Recommended Posts

I have read all of the posts already on this topic but I cannot interact with the "Choose File to Upload" dialog that is used when uploading files with IE8. Basically the problem comes down to the fact that I cannot seem to get a handle to the "Choose File to Upload" window. I am running Selenium and executing a compiled version of my script.

If I write a simple script that just waits for the "Choose File Upload" window and manually make the window show, I can enter the data into the File textbox with no problem.

$hWnd = WinWait("Choose File to Upload")

MsgBox(0,"window handle",$hWnd)

If $hWnd Then


ControlClick($hWnd, "", "Button2")


here is my code that has a problem:

#include <IE.au3>

If $CmdLine[0] Then

; Internet Explorer is partly integrated in shell.application

$oShell = ObjCreate("shell.application") ; Get the Windows Shell Object

$oShellWindows=$oShell.windows ; Get the collection of open shell Windows


for $Window in $oShellWindows ; loop through all existing shell windows

if StringInStr($window.LocationURL,"ImportProcessPopup") then





; find the Browse Button and Click it

$oFileUpload = _IEGetObjByName ($MyIExplorer, "iFile") ;need iFile to be a param

_IEAction($oFileUpload, "click")

; wait for File Upload dialog to open

$hWnd = WinGetHandle("Choose File to Upload")

; if File Upload dialog opens send the file name and click enter

If $hWnd Then


ControlClick($hWnd, "", "Button2")



Edited by JimCarter
Link to comment
Share on other sites

I spoke too fast. It seems that my compiled AutoIT script only works if it is running prior to running my sellenium tests in C#. Does anyone have any experience with the combo of Sellenium, C# and AutoIT? The main two methods are shown below.

public static void SelectImportToProcess(Import import)


if (import == null)

throw new ArgumentNullException("import");

//find the process link and click on it and wait for popup

string importXPath =

"//a[contains(@href, \"ImportID=" + import.Id.ToString(CultureInfo.CurrentCulture.NumberFormat) + "\")]";

ClickAndWaitForPopup(importXPath,"Import Process Popup");


public static void UploadFile(string filePath, string fileTextBoxLocator)


//uses AutoIt to handle communication with the Choose File To Upload dialog

var procStartInfo = new System.Diagnostics.ProcessStartInfo(@"C:\Grow\Utilities\Grow.Selenium\SharedBinaries\BrowseButton.exe", filePath);

var proc = new System.Diagnostics.Process {StartInfo = procStartInfo};




if (proc.HasExited)






Link to comment
Share on other sites

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