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.

Help reqd: Verfiying a file ulpload in popup window

nilpnilp Members
edited November -1 in Sahi - Open Source
Hi,
I am new to Sahi. I am trying check the file upload element in a popup window. The assertion for file is failing. I am not able o figure out wats the problem. I was able to verify links, buttons & texts. Please reply asap.


Below is the script that I used:


function checkUsr($username,$password)
{

//Form.jsp
_setValue(_textbox("username"),$username);
_setValue(_password("pass"),$password);

_click(_submit("submit"));

//success.jsp
_assertNotNull(_link("Back"));
_assertNotNull(_link("popLink"));
_assertExists(_span("msg"), "This is success page.");


//pop.jsp
_click(_link("popLink"));
_assertExists(_popup("popup")._span("popMsg"), "This is a popup window");
_assertNotNull(_popup("popup")._setFile(_file("test_file"), "test.txt"));
_assertExists(_popup("popup")._button("popClose"));
_assertNotNull(_popup("popup")._submit("submit"));
_click(_popup("popup")._button("popClose"));
_navigateTo("/SahiExample/Form.jsp");
}

//test cases

//valid data
checkUsr("nilesh","jug");

//password empty
checkUsr("nilesh","sdf");

//username empty
checkUsr("sdf","jug");

//empty username & password
checkUsr("sdfd","sd");



Following is the Log:

_setValue(_textbox("username"),"nilesh"); at Dec 30, 2010 10:50:54 AM
_setValue(_password("pass"),"jug"); at Dec 30, 2010 10:50:54 AM
_click(_submit("submit")); at Dec 30, 2010 10:50:54 AM
_assertNotNull(_link("Back")); at Dec 30, 2010 10:50:55 AM
_assertNotNull(_link("popLink")); at Dec 30, 2010 10:50:55 AM
_assertExists(_span("msg"), "This is success page."); at Dec 30, 2010 10:50:55 AM
_click(_link("popLink")); at Dec 30, 2010 10:50:55 AM
_assertExists(_popup("popup")._span("popMsg"), "This is a popup window"); at Dec 30, 2010 10:50:56 AM
_assertNotNull(_popup("popup")._setFile(_file("test_file"), "test.txt"));
Assertion Failed. at Dec 30, 2010 10:51:06 AM
_assertExists(_popup("popup")._button("popClose")); at Dec 30, 2010 10:51:08 AM
_assertNotNull(_popup("popup")._submit("submit")); at Dec 30, 2010 10:51:08 AM
_click(_popup("popup")._button("popClose")); at Dec 30, 2010 10:51:08 AM
_navigateTo("/SahiExample/Form.jsp"); at Dec 30, 2010 10:51:08 AM

Comments

  • narayannarayan Administrators
    Hi Nilesh,

    Replace popup code with this:
    //pop.jsp
    _click(_link("popLink"));
    _selectWindow("popup"); // Using _selectWindow to remove _popup duplication
    _assertExists(_span("popMsg"), "This is a popup window");
    
    // What are you trying to do here? This seems totally incorrect.
    // _assertNotNull(_setFile(_file("test_file"), "test.txt")); 
    
    _assertExists(_file("test_file")); // checking that the file field exists
    
    _assertExists(_button("popClose"));
    _assertNotNull(_submit("submit"));
    _click(_button("popClose"));
    
    _selectWindow(); // select base window again.
    _navigateTo("/SahiExample/Form.jsp");
    

    Regards,
    Narayan
  • nilpnilp Members
    Hey Thanks Narayan!
    This worked.




    -Nilesh
This discussion has been closed.