Unable to upload file even using autoit as my IE browser taking long to open upload windows popup



    1. Unable to upload file even using autoit as my IE browser taking long to open upload popup once we click on the browse button but my script runs when i execute manually.

    2. Also my objective is, i need to export a file and next step is to upload the latest timestamp file from the exported files. Can we handle these kind of scenario using AutoIT or if any please suggest.

    3. One more step is to open and edit the exported excel file and import the same file.

    Please suggest me with ur thoughts on it.

    Script used for upload:

    WinWaitActive("Choose File to Upload","",10)
    Sleep(1000)
    ControlFocus("Choose File to Upload","","Edit1") ; FILE UPLOAD
    Sleep(2000)
    ControlSetText("Choose File to Upload","","Edit1",""C:\Desktop")
    Sleep(2000)
    ControlClick("Choose File to Upload","","Button1") ; CLICK ON OPEN BUTTON
    Sleep(1000)
    


  • Depending on what you are testing (i.e. the actual process of using the upload control, or just the ability to upload / validate a file) you can skip the upload popup entirely. This also means you don't need autoit (which will mean you can run the tests on unattended (locked) machines.

    e.g. Generally any upload button will be something like the below when viewed in the DOM:

    <input type="file", id="File", name="import", accept=".csv">
    

    You can just manipulate that directly (example in java):

    By fileUpload = By.id("File");
    
    public void uploadFile(String filePath) {
        wait.until(ExpectedConditions.visibilityOfElementLocated(fileUpload));
        wait.until(ExpectedConditions.elementToBeClickable(fileUpload))
        driver.findElement(fileUpload).sendKeys(filePath);
    
        }
    
    

    Then just click your upload / save / etc button.

    Alternatively add some explicit waits (wait until condition met, as per above) to wait for things rather than implicit (always waiting a set amount of time).



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2