18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

how to automate testing of Uploading photo or files in a website.

ranjprashantranjprashant Members
edited November -1 in Sahi - Open Source
i want to automate testing on Uploading a file and images, where clicking uploading icon open a new pop-up window to select files and after selecting file clicking "OK" Button files get uploaded.


Thanks.
Prashant Ranjan.

Comments

  • Hi Prashant,

    Kindly have a look at : http://sahi.co.in/w/_setFile

    Let me know if you face any problem.

    Regards
    Sumitra
  • hi...i'm not able to get the solution from it.
  • Hi Prashanth,

    Here is an example which would help you to understand how to set a file through Sahi:
    _navigateTo("http://sahi.co.in/demo/php/fileUpload.htm");
    _setFile(_file("file"), "C:\\trial\\trial.doc.docx");
           // Change the "type" attribute of file field
        if (_isIE()){
            _call(_file("file").outerHTML = _file("file").outerHTML.replace(/type=file/, "type=text"));
            _call(_textbox("file").value= "C:\\trial\\trial.doc.docx");
        }else{
            _call(_file("file").type = "text");
        }
            // Set the value into the textbox
        _setValue(_textbox("file"), "C:\\trial\\trial.doc.docx");
    _click(_submit("Submit Array"));
    

    Let me know if you face any problem.

    Regards
    Sumitra
  • i want to send the screen shots of my web page and also what error i'm getting. how to do so.
  • Hi Sumitra,
    I have sent the mail as the ID u mentioned with screen shots and some results which i'm getting.
  • Hi Prashanth,

    If you want to send the screen shot and the errors what you are getting then you can send it to support@sahi.co.in

    Or If you trying to upload a file that are the screenshots then you can use the way i have mentioned earlier.
    _navigateTo("http://sahi.co.in/demo/php/fileUpload.htm");
    _setFile(_file("file"), "C:\\Documents and Settings\\Sumitra\\My Documents\\Downloads\\IE8_Sahi_JavaScriptError.jpg");
           // Change the "type" attribute of file field
        if (_isIE()){
            _call(_file("file").outerHTML = _file("file").outerHTML.replace(/type=file/, "type=text"));
            _call(_textbox("file").value= "C:\\Documents and Settings\\Sumitra\\My Documents\\Downloads\\IE8_Sahi_JavaScriptError.jpg");
        }else{
            _call(_file("file").type = "text");
        }
            // Set the value into the textbox
        _setValue(_textbox("file"), "C:\\Documents and Settings\\Sumitra\\My Documents\\Downloads\\IE8_Sahi_JavaScriptError.jpg");
    _click(_submit("Submit Array"));
    

    Let me know if you face any problem.

    Regards
    Sumitra
  • Hi Sumitra,
    The code which you have sent to me is working fine for the demo link sent by you, but its not working for my app , regarding this i have sent the mail to the support team.
  • Hi Prashant,

    Kindly let me know you availability so that we can have a desktop sharing and will help you to solve the problem.

    Regards
    Sumitra
Sign In or Register to comment.