Search code examples
javaeclipseselenium-webdriverautoit

How to upload multiple files by using AutoIt?


I am using below code:

ControlFocus("File Upload","","File1")
ControlSetText("File Upload","","File1",'"C:\Users\Desktop\image1.png" "C:\Users\Desktop\image1.png" "C:\Users\Desktop\image2.png" "C:\Users\Desktop\image3.png" "C:\Users\Desktop\image4.png" "C:\Users\Desktop\image5.png" "C:\Users\Desktop\image6.png" "C:\Users\Desktop\image7.png" "C:\Users\Desktop\image8.png" "C:\Users\Desktop\image9.png"')
ControlClick("File Upload","","Button1")

I have run this code files getting, but not stored. Entered in manually files stored

what was the problem.If any one help me please.


Solution

  • Example how to automate a window is shown below. In order to save content to a file you need first to open it.

    var autoit = new AutoItX3Lib.AutoItX3();
    var windowWait = autoit.WinWaitActive("[CLASS:#32770]", "", 10);
    
    Console.WriteLine("...Surviving the IE security window handler");
    //  autoit.WinWaitActive("Beveiligingswaarschuwing", "Ja");
    
    autoit.ControlSend("Beveiligingswaarschuwing", "", "", "{TAB}");
    
    autoit.Sleep(500);
    autoit.ControlSend("Beveiligingswaarschuwing", "", "", "{ENTER}");
    
    autoit.Sleep(500);
    autoit.ControlSend("Beveiligingswaarschuwing", "", "", "{TAB}");
    
    autoit.Sleep(500);
    autoit.ControlSend("Beveiligingswaarschuwing", "", "", "{ENTER}");
    
    autoit.Sleep(500);
    autoit.ControlSend("Beveiligingswaarschuwing", "", "", "{TAB}");
    
    autoit.Sleep(500);
    autoit.ControlSend("Beveiligingswaarschuwing", "", "", "{ENTER}");
    
    
    autoit.Sleep(500);
    autoit.ControlSend("Beveiligingswaarschuwing", "", "", "{TAB}");
    
    
    autoit.Sleep(500);
    autoit.ControlSend("Beveiligingswaarschuwing", "", "", "{ENTER}");
    

    image1

    image2