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.

assert function not running in popup window

aspatel80aspatel80 Members
edited November -1 in Sahi - Open Source
Hi Team,

I have the following code to check whether a name exists in my popup window:

_click(_link("My Clients"));
_click(_submit("Search"));
_click(_link("Create Client"));
_setValue(_textbox("ctl00\$ContentPlaceHolder1\$ucClientDetail\$tbClientName"), "New Client");
_setSelected(_select("ctl00\$ContentPlaceHolder1\$ucClientDetail\$ddlClientType"), "Private");
_click(_link("Add Person"));
_popup("IndividualList")._setValue(_textbox("ctl00\$ContentPlaceHolder1\$ucCRMContactSearch\$tbSearchName"), "Patel");
_popup("IndividualList")._click(_submit("Search"));
if(_condition(_popup("IndividualList")._assertExists(_link("Jigar Patel"))))
{
_log("CRM Contact Search Test Case - Pass");
}
else
{
_log("CRM Contact Search Test Case - Pass");
}

Now, what happens that Im able to insert name to the search box of the popup window named "IndividualList" but when checking for the existence of name in the system by specifying the last name and using asserExists() method, the script fails giving me the message:

SahiNotMyWindowException: Window with name [IndividualList] not found

How can it be that IndividualList popup window is not found even though text has been specified before in the same window. Error came at if() statement.

If anybody can respond me quickly, that would be great.

Thanks.

Regards,
Ashvin.

Comments

  • narayannarayan Administrators
    Do this:
    _popup("IndividualList")._set($doesLinkExist,  _link("Jigar Patel") != null);
    
    if($doesLinkExist)
    {
        _log("CRM Contact Search Test Case - Pass");
    }
    else
    {
        _log("CRM Contact Search Test Case - Pass");
    }
    
  • Hi Narayan,

    Thanks for the post. I tried it. The new error is:

    ReferenceError: _set is not defined

    Please Help. :(

    Regards,
    Ashvin.
  • narayannarayan Administrators
    Hmm, seems like we need to refine the _popup() api.

    Meanwhile try this:
    <browser>
    function logStatus(){
      if (_link("Jigar Patel") != null){
         _log("CRM Contact Search Test Case - Pass");
      } else {
         _log("CRM Contact Search Test Case - Fail");
      }
    }
    </browser>
    
    _popup("IndividualList")._call(logStatus());
    
  • Hi Narayan,

    Thanks for the post. If you can just give updated API for _popup(), it would be great.

    The code which you have given contains <browser> & </browser>. I didnt get them; why to put the code in a tag while I have never used it throughout my testing.
Sign In or Register to comment.