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.

unable to compare message on pop up window.

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

Code:

_click(_link("Raise Gatepass"));
_setValue(_textbox("ctl00\$cphPage\$txtFirstName"), "M545ohit");
_setValue(_textbox("ctl00\$cphPage\$txtLastName"), "Jain");
_click(_submit("Add"));

if (/[^a-zA-Z.']/.test(_getText(_textbox("ctl00\$cphPage\$txtFirstName")))) {
_assertEqual("First Name can contain only letters a-z or A-Z or '.' or apostrophe ' ",_lastAlert());

}


Log file:
_assertEqual("First Name can contain only letters a-z or A-Z or '.' or apostrophe ' ",_lastAlert());
Assertion Failed.
Expected: [First Name can contain only letters a-z or A-Z or '.' or apostrophe ' ]
Actual : [First Name can contain only letters a-z or A-Z or ‘.’ or apostrophe ‘ ] at Feb 23, 2012 5:24:02 PM


Please help me to solve above issue. how to verify single quotes and apostrophe.

Thnaks
Mohit

Comments

  • narayannarayan Administrators
    Hi Mohit,

    The alert seems to have magic quotes instead of regular quotes. Just copy the text in "Actual" into your _assertEqual. Like below:

    _assertEqual("First Name can contain only letters a-z or A-Z or ‘.’ or apostrophe ‘ ", _lastAlert());

    Regards,
    Narayan
  • Hi Narayan,

    Thanks for reply.
    I tried above solution but its not working..
    Code:

    if (/[^a-zA-Z.']/.test(_getText(_textbox("ctl00\$cphPage\$txtFirstName")))) {
    _assertEqual("First Name can contain only letters a-z or A-Z or ‘.’ or apostrophe ‘ ",_lastAlert());

    }

    Log file:
    _assertEqual("First Name can contain only letters a-z or A-Z or �.� or apostrophe � ",_lastAlert());
    Assertion Failed.
    Expected:[First Name can contain only letters a-z or A-Z or �.� or apostrophe � ]
    Actual:[First Name can contain only letters a-z or A-Z or ‘.’ or apostrophe ‘ ] at Feb 24, 2012 9:38:04 AM

    Please help
    Mohit
  • Hi Mohit198,

    When you try to copy the contents from the webpage to your text editor, the content comes up with some special characters like �.

    As Narayan said, these characters should be removed and the content should be made "Actual" (without any special characters).

    Then the _assertEqual() willbe carried out between two actual strings and return either "true" or "false".

    Regards,
    Theeran.
  • Hi Theeran,

    i have copied contents from log file. the single quote copied from log file is not recognized be sahi while executing the script.
    In above post the special char is nothing but single quote from log file.

    Please suggest how to solve this...

    Mohit
  • Hi All,

    Please help for above post.

    Mohit
Sign In or Register to comment.