Forum Discussion

velise's avatar
velise
Occasional Contributor
13 years ago

How to upload file in an html page

Hello,

I'm a new user of test complete and i'm writting a script to test my Web application.

I have to upload a file on server by using the "fileupload" object of a form...



I have no idea how to do this.

Can someone explain me ?

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Probably the easiest way to get started is to try recording what you want to do and examine the resulting script or keyword test.  
  • velise's avatar
    velise
    Occasional Contributor
    Thank's a lot. I manage with my upload !
  • Thanks a lot for the suggestion. For my needs, I eventually came up with the following solution. It works fine on IE8 and Win 2003 server. Haven't tested it yet on Firefox or other systems.



    ****************************************

    Set Page = iexplore.Page("*")



    ' Click on Install button



    InstallObj = page.EvaluateXPath("//*[@id='install.button']")



    InstallObj(0).Click



    ' Double click on file input to add a file

    BrowseObj = page.EvaluateXPath("//*[@id='file.input']")


    BrowseObj(0).DblClick


     



     



    ' Add path to the file using sendkeys

     




     



     



    Sys.Desktop.Keys("C:\Users\me\Desktop\myzip.zip")

     


     



     



    Sys.Desktop.Keys("[Enter]")

     


     



     



    aqUtils.Delay 2000

     


     



     



    ' Click the OK button

     




    OKObj = page.EvaluateXPath("//*[@id='box.ok']")


    OKObj(0).Click


    OKObj(0).Click

    *****************************************