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 browse the file and upload to the database

shiprashipra Members
edited November -1 in Sahi - Open Source
below is the scenario:

When some button is clicked a popup is opened having a browser button and import button
2. On clicking the browse button it Will open a "file browser" to select the desired file.
3. the user will browse and select the file and click on Open.
4. On clicking the import button, the selected file will be uploaded to the DataBase.

i am not able to record these scenarios. please tell me the exact code need to be written for complete scenario

I have used _setFile(_file("fileid") , path) but there is error coming that form name not is null.

then I entered (Form name:FileId) then showing error as name is null.

any body pls help.. its very urgent.

thanks,
shipra

Comments

  • I have the same issue. Is there any bypass? _setFile does not work for me because the developer have restricted the set option and a message comes that browse and select the file to upload. It can not be set.

    Is there any way to automate this using sahi?
    Can we call an external exe or program to do this?

    Thanks,
    Rahul
  • Hi iwx1,

    Yes, you can modify any part of code in the application using sahi (by modifying methods & attributes of any object).

    If your issue is same as Shipra then : It looks like a new window is opened when you click on Submit button. If that is the case, you need to add _popup("") before the steps that happen on the newly opened window.

    Here is an example:

    http://sahi.co.in/forums/viewtopic.php?id=1920

    For more details about _setFile() have a look at :

    http://sahi.co.in/w/_setFile

    Let me know if you face any problem.

    Regards
    Sumitra
  • Hi Sumitra,

    Thanks for your reply.

    I will try it out again.

    Regards,
    Rahul
  • Hi Shipra,

    Pls try this ,

    _setFile(_file("versionFile"),"path");

    if (_isIE())
    {
    _call(_file("versionFile").outerHTML = _file("versionFile").outerHTML.replace(/type=file/, "type=text"));
    }
    else
    {
    _call(_file("versionFile").type = "text");
    }
    _setValue(_textbox("valueEditable"),"path");
    _setValue(_textbox("name"), "File name");
    _click(_button("Add"), "Add");
    add or submit whatever is the import one.

    try
    {
    if(_getCellText(_table("errorBox[1]")).indexOf("Error adding new item") > 0)
    {
    _navigateTo("path",true);
    > path where you want to navigate
    }
    }
    catch(e){}
  • P2pP2p Members
    Hi..
    can you please tell what is "VersionFile" depicts in "_setFile(_file("versionFile"),"path");"
    As i have to upload file to the application from any drive. and not getting exact syntax for that

    thank you
  • "VersionFile" means, where u want to set the file. The Accessor name of that upload file button/Field.
Sign In or Register to comment.