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.

Clicking on button does not pop up window

Nish007Nish007 Members
edited November -1 in Sahi - Open Source
Hi
I have used Sahi to record the action below:

_click(_file("awd_cs_file")); \\This is a "browse" button

When i click on the "browse" button manually, it brings up a window so that i can select a file to upload, but when sahi does it, the window does not pop up

The log file shows that the action was performed fine

I have tried the alternatives but nothing brings up that window

Comments

  • Hi Nish007,

    Sahi handles file upload using _setFile() API.

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

    Let me know if you face any problem.

    Regards
    Sumitra
  • Hi Sumitra, I've tried this: _setFile(_file("file_input"), "C:\\sahi\\userdata\\scripts\\source.pdf", "formSubmit.jsp");

    but its still having no effect
  • Hi Nish007,

    First of all "formSubmit.jsp" is the actionURL(ie The form action URL to which the file is submitted. This is an optional parameter. Use it in cases where the form’s action URL is changed on setting the file. By default, it uses the form’s current action URL.)

    Try using this:
    // set the file
        _setFile(_file("file_input"), "C:\\sahi\\userdata\\scripts\\source.pdf");
           // Change the "type" attribute of file field
        if (_isIE()){
            _call(_file("file_input").outerHTML = _file("file_input").outerHTML.replace(/type=file/, "type=text"));
        }else{
            _call(_file("file_input").type = "text");
        }
            // Set the value into the textbox
        _setValue(_textbox("file_input"), "C:\\sahi\\userdata\\scripts\\source.pdf");
    

    Check if this solves your issue.

    Regards
    Sumitra
  • Hi Sumitra

    This code did do something this time
    It put the file path in the text box and when the "create" button is clicked, I now get a message from the app saying "There was a problem with this request. Check file names for correctness."

    I have checked the path and it is correct. I have even changed the path but it still giving me the error
  • Hi Nish007,

    Could you post the exact script which you used?

    Also, if your application is accessible outside then could you please share the URL?

    Check if you are getting any error on Sahi console and Logs? If so then please post it here.

    Regards
    Sumitra
  • Hi, The app is not available outside

    The code is below:
    function createSource ($businessArea, $workType, $contractNumber)
    {
    _click(_link("Create"));
    _click(_image("Add Create[1]"));
    _click(_link("Create Source"));
    _wait (1000);
    _setSelected(_select("awd_cs_unit_select"), $businessArea);
    _setSelected(_select("OBJT"), $workType);
    //set the file
    _setFile(_file("file_input"), "C:\\sahi\\userdata\\scripts\\source.pdf");
    // Change the "type" attribute of file field
    if (_isIE()){
    _call(_file("file_input").outerHTML = _file("file_input").outerHTML.replace(/type=file/, "type=text"));
    }else{
    _call(_file("file_input").type = "text");
    }
    // Set the value into the textbox
    _setValue(_textbox("file_input"), "C:\\sahi\\userdata\\scripts\\source.pdf");
    _wait(1000);
    _click(_button("Create"));
    }

    The log does not show any errors but it does show a warning at the beginning of the script:

    undefined: (ActiveX)AWDXMLDom.createAndLoadDocument
    xml/ externalDD . xml, async=false)Error code: -1072896683, reason: Only one top level element is allowed in an XML document.
    No trace available
    Click for browser script at Jan 31, 2012 9:51:48 AM

    I removed some lines or it wont let me post it
  • Hi Nish007,

    If there are any warnings then ignore as far as it does not effect your playback of the script.

    Could you please try using:

    "C:/sahi/userdata/scripts/source.pdf"

    instead of

    "C:\\sahi\\userdata\\scripts\\source.pdf"

    and check if this works for you.

    Also, make sure that the pdf is in the correct path.

    Regards
    Sumitra
Sign In or Register to comment.