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.

need help with _title() and if compare syntax

rj412rj412 Members
edited November -1 in Sahi - Open Source
I'm trying to create my common function for verify links...please help

function checkLinks ( $element) {
var $pageTitle = _title() ; //Page Title is: "Bla Bla Page 1 Bla Bla"
if ( $pageTitle == /Page 1/ ) {
_debug ( "True" ) ;

_popup(/Page 1/)._highlight(_link($element));
_popup(/Page 1/)._assertExists(_link($element));
_popup(/Page 1/)._assert(_isVisible(_link($element)));
} else {
//Parent Page:
._highlight(_link($element));
_assertExists(_link($element));
_assert(_isVisible(_link($element)));
}


}

CheckLinks ( "Link1" ) ;


//I also tried
if ( _containsText(_title(), /Page 1/ ) {
_debug ( "true" );
}

Comments

  • You can close this discussion....Thanks Narayan for your help....

    Here's the solution (email from Narayan) for those with the same problem:

    "A single character is represented by a . (dot)
    Any number of characters is .*

    You need to use:
    //Title of this page is Page1
    _popup("/Title .* this page is.*/")

    (This is different from the other APIs, in that it needs the end .* too. For normal Sahi APIs, just _button("/Title .* this page is/") would have worked. We are looking into this.)

    Regards,
    Narayan"
This discussion has been closed.