18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
_getText issue
Basically I'm creating and assigning a new variable by grabbing the links ID with _getText
/*
*/
_popup($popupWindow)._assertExists(_link("1"));
//var $DocHeadline = _popup($popupWindow)._getText(_link("1"));
//var $DocHeadline = _getText(_link("1"));
var $DocHeadline = "This is the 'link and headline' name compare test" ;
_popup($popupWindow)._click(_link("1"));
_popup($popupWindow)._assertExists(_heading3(0));
_popup($popupWindow)._assertEqual($DocHeadline, _getText(_heading3(0)));
/*
*/
(Think news.google.com ; before clicking on the link, get its ID, then click it and make sure that it opened the correct page by checking its heading)
Eventually what I really want to achieve is to a compare of:
_getText(_link("1")) is equal to _getText(_heading3(0))
both are captured with _getText BUT at different times (since _heading3(0) is only available after _link("1") has been clicked to load the doc on that page).
And if I manually hard-code $DocHeadline (line 4 of code above) - the test works.
So it has to be the _getText(_link) syntax or bug. Please help.
/*
*/
_popup($popupWindow)._assertExists(_link("1"));
//var $DocHeadline = _popup($popupWindow)._getText(_link("1"));
//var $DocHeadline = _getText(_link("1"));
var $DocHeadline = "This is the 'link and headline' name compare test" ;
_popup($popupWindow)._click(_link("1"));
_popup($popupWindow)._assertExists(_heading3(0));
_popup($popupWindow)._assertEqual($DocHeadline, _getText(_heading3(0)));
/*
*/
(Think news.google.com ; before clicking on the link, get its ID, then click it and make sure that it opened the correct page by checking its heading)
Eventually what I really want to achieve is to a compare of:
_getText(_link("1")) is equal to _getText(_heading3(0))
both are captured with _getText BUT at different times (since _heading3(0) is only available after _link("1") has been clicked to load the doc on that page).
And if I manually hard-code $DocHeadline (line 4 of code above) - the test works.
So it has to be the _getText(_link) syntax or bug. Please help.
Comments
Use:
var $DocHeadline;
_popup($popupWindow)._set($DocHeadline, _getText(_link("1"));
We are verifying why your construct did not work.
Regards,
Narayan
//The following works if I run _getText on the parent page
_debug(_getText(_link("1")));
//But when run with a child page, it no longer works
var popupWindow = "/Page 1/";
//_debug(_popup($popupWindow)._getText(_link("1")));
//Also tried the _set as per your instructions...
var $DocHeadline;
_debug(_popup($popupWindow)._set($DocHeadline, _getText(_link("1"))));
None of this seem to work.
Please help.
Thanks.
_popup() is a prefix to tell Sahi that whatever follows needs to be executed on a popup.
_debug(_popup($popupWindow)._getText(_link("1")));
should be
_popup($popupWindow)._debug(_getText(_link("1")));
Why do we have both _debug and _set in the same line? _set does not return any value. It just sets $DocHeadline with _getText(_link("1"))
The following code should work:
Regards,
Narayan
Let me explain why:
With hard-coded popup Window Title is used- both of these operation work.
But once popup window is reference with /.* -xxxxx- .*/ - the same operations no longer work: getting [Exception][object Object]
//when _exists works with _popup
_popup("Test Page - This is only a Test - user1 (Sample/User/Text)")._exists(_div("This user has already been taken"));
//when it does not work with a reference popup
var $popupWindow = "/.*This is only a Test.*/" ;
_popup($popupWindow)._exists(_div("This user has already been taken"));
//when it does not work with a reference popup
var $popupWindow = "/.*This is only a Test.*/" ;
var $condn = false;
_popup($popupWindow)._set($condn, _exists(_div("This user has already been taken")));
_debug($condn) ;
//when _getText works with _popup
_popup("Test Page - This is only a Test - user1 (Sample/User/Text)")._getText(_div("This user has already been taken"));
//when it does not work with a reference popup
_popup($popupWindow)._getText(_div("This user has already been taken"));
//when it does not work with a reference popup
var $popupWindow = "/.*This is only a Test.*/" ;
var $ReadText ;
_popup($popupWindow)._set($ReadText, _getText(_div("This user has already been taken")));
_debug($ReadText) ;