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.
how can we put _getText value in a variable?
I tried using _getText value to store a string obtained from UI in a var but returned
here's is the code -
var $isMFAEnable = "";
$isMFAEnable = _getText(_link("Where do I enter my password?"));
PrintOnCommandPrompt($isMFAEnable);
it printed [object Object]
i also tried _set($isEnable, _getText(_link("Where do I enter my password?")));
it works fine; but if the link is not present the scripts stops there.
Where as i want the script to execute into the 'else' statement 'if' the above link is not found
Can someone give me a solution?
here's is the code -
var $isMFAEnable = "";
$isMFAEnable = _getText(_link("Where do I enter my password?"));
PrintOnCommandPrompt($isMFAEnable);
it printed [object Object]
i also tried _set($isEnable, _getText(_link("Where do I enter my password?")));
it works fine; but if the link is not present the scripts stops there.
Where as i want the script to execute into the 'else' statement 'if' the above link is not found
Can someone give me a solution?
Comments
var $isEnable;
try{
_set($isEnable, _getText(_link("Where do I enter my password?")));
$isEnable = true;
}catch(e){
$isEnable = false;
}
thanks a ton :-)
Maverick:
That answer is technically correct, but not really a good test. You are identifying an element by a string and then verifying that that string is present in the element. Instead you should identify the span by some other property and then check whether its content is right. One good thing would be to use _span("span_id"), if that span has an id.
Another would be to look for the text in the document body itself.
_set($enable, _containsText(document.body, "Where do I enter my password?"));
Let me know what you guys think.
Regards,
Narayan
Thanks a lot for your input
dp