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.

Can we use _lastConfirm() in _assertContainText?

mohit198mohit198 Members
edited November -1 in Sahi - Open Source
Hi All,

I want to verify text of last confirm message using _assertContainText. but its giving error as below.
Code:
_assertContainsText("First Name can contain only letters a-z or A-Z or",_lastAlert(),"Incorrect message");

Error:
_assertContainsText("First Name can contain only letters a-z or A-Z or",_lastAlert(),"Incorrect message");
TypeError: 'undefined' is null or not an object
No trace available
Click for browser script

I cant use _assertEqual as some part of the message has megic quote. so i want to verify part of the _lastConfirm mesage using _assertContaintext.

Please help.

Thanks & Regards,
Mohit

Comments

  • Hi

    as far as i know, _lastConfirm() returns a string, so you can't use the _assertContainsText. If you want an equal behavior, use _assertTrue(_lastConfirm.match("Yourtext"))

    Regards
    Wormi
  • Hi Wormi,

    Thanks for reply.

    Actualy i want to verify part of _lastAlert and _assertTrue checks for complete message.

    Reason for this is because there is some megic single quotes in the message and i am not able to compare this megic single quotes in SAHI. Sahi doesnt recognize these quotes.

    code:
    var $a = _lastAlert();
    _debug($a);
    _assertTrue(_lastAlert().match("First Name can contain only letters a-z or A-Z or"));

    Log file:

    _debug("First Name can contain only letters a-z or A-Z or ‘.’ or apostrophe ‘ "); at Mar 14, 2012 2:50:08 PM
    _assertTrue(_lastAlert().match("First Name can contain only letters a-z or A-Z or"));
    Assertion Failed. at Mar 14, 2012 2:50:19 PM

    Please help on this

    Thanks & Regards,
    Mohit
Sign In or Register to comment.