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.

Identifying popup title/popup exists or not

zerenzeren Members
edited November -1 in Sahi - Open Source
Hi,
I need to verify whether a poup is displayed and which popup is getting loaded when a click is performed. I tried many ways , When I assert using sahi controller, it identifies the popup and returns correct title. But when runs the script, it could not identify popup title, it shows parent window titile.

Is there a way to make sahi to identify popup title when suite/script runs?

Thanks.



_click($sId);
var $popupTtile;
_set($popupTtile,window.document.title );

var $advPExists = false;
if($popupTtile == "X"){
_popup("X")._assertExists(_span("XXXTabNavButton1"));
_popup("X")._assertExists(_div("XXXControls"));
//steps for x window
_popup("X")._closeWindow();
$advPExists = true;
}else if($popupTtile == "Y"){
_popup("Y")._assertExists(_span("XXXTabNavButton1"));
_popup("Y")._assertExists(_div("XXXControls"));
//steps for y window
_popup("Y")._closeWindow();
$advPExists = true;
}



Env: Windows XP . browser IE8. Sahi Build: 2011-05-25.

Comments

  • Did you get a solution for this? I am also looking for this info.
  • I referred to lot of solution here in the forum but nothing seem to work.

    I tried with this code and nothing seem to happen.
    Any help is greatly appriciated.

    var $popupWindow = "something";
    var $condn ="";
    _popup($popupWindow)._set($condn, _exists(_cell("Details")));
    if($condn)
    {
    _debug("Window Exists");
    }
  • Hi keats,

    Use this:
    var $popupName = "something";
    if(_condition(_exists(_popup($popupName)._cell("Details"))))
           _debug("Window exists");
    

    Check if this solves your issue.

    Regards
    Sumitra
  • No!! It does not seem to work.
    when I ran the following Code it does not do anything. Doesnt even give "Sucess" or "failure" message.

    var $popupWindow = "Processing";
    if(_condition(_exists(_popup($popupWindow)._cell("Details"))))
    {
    _debug("Window exists");
    }else
    {
    _debug("No exists");
    }
  • Hi keats,

    Kindly Ctrl+Hover on _cell("Details") on the popup window and check what the controller is identified the popup as?

    Use the prefix of the popup which is identified by the controller.

    The below code works for me with http://sahi.co.in/demo/ as the start URL.
    _navigateTo("http://sahi.co.in/demo");
    _click(_link("Window Open Test"));
    var $popupName = "popWin";
    if(_condition(_exists(_popup($popupName)._link("Confirm Page"))))
    {
             _debug("Window exists");
    }else
    {
             _debug("No exists");
    }
    

    Regards
    Sumitra
  • keatskeats Members
    edited December 2011
    Did you try the negative case? Like, what if the window does not exists?
    For me, when the window is not present with the name specified in _popup(), it fails.
    Most of the time it works if the window is present.
Sign In or Register to comment.