Jump to content

JimCarter

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by JimCarter

  1. Wow, what a pain. I found another post dealing with a security restriction workaround. I guess you can't directly click the IE fileupload control using: _IEAction($oFileUpload, "click") You need to move the mouse and do a MouseClick instead: MouseMove(_IEPropertyGet($oFileUpload, "screenx") + _IEPropertyGet($oFileUpload, "width") - 10, _ _IEPropertyGet($oFileUpload, "screeny") + _IEPropertyGet($oFileUpload, "height")/2) MouseClick("left")
  2. Well, I got my AutoIT script to work, but it only works if the executable is loaded prior to running my Selenium tests. I am utilizing AutoIT to allow my to upload files because of the IE security restrictions surrounding javascript and the file uploader. I need to be able to start AutoIT processes and shut them down in my different tests, maily because I need to specify different file paths. The following is my C# code I am using to load my compiled AutoIT script that will click the browse button, find the "Choose File to Upload" window, specify the file path and click the Open button. Again, this all works fine if I have a version of the AutoIT script exe running prior to my Sellenium tests. Otherwise the behavior is that the Browse button is clicked by my AutoIt script successfully but the "Choose File to Upload" dialog box just sits there and the file is never specified. I am assuming it can't find the window handle for some reason... 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}; proc.Start(); proc.WaitForExit(5000); proc.Kill(); if (proc.HasExited) { ClickAndWait("//input[@id='btnUpload']"); ClickAndWait("//input[@value='Save']"); } }
  3. 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}; proc.Start(); proc.WaitForExit(5000); proc.Kill(); if (proc.HasExited) { ClickAndWait("//input[@id='btnUpload']"); ClickAndWait("//input[@value='Save']"); } }
  4. OK, I it was material. Changing too many things at one time. It is working now - thanks
  5. It's not material. I get the same behavior when I use WinWait.
  6. 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 ControlSetText($hWnd,"","Edit1","Test") ControlClick($hWnd, "", "Button2") EndIf 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 $MyIExplorer="" for $Window in $oShellWindows ; loop through all existing shell windows if StringInStr($window.LocationURL,"ImportProcessPopup") then $MyIExplorer=$Window exitloop endif next ; 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 ControlSetText($hWnd,"","Edit1",$CmdLine[1]) ControlClick($hWnd, "", "Button2") EndIf EndIf
×
×
  • Create New...