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.

how to include/exclude the new line character(\n) in the Html Report

AdmirerAdmirer Members
edited November -1 in Sahi - Open Source
Hi,

While testing my application one of the popup string contains as follows in the view source: "Minimum Length of password is 6 And Max Length is 10.\n"

My code as follows:
$expValue = "Minimum Length of password is 6 And Max Length is 10."
_set($actualValue, _lastAlert());
_alert($actualValue);

_assertEqual($expValue,$actualValue,"Popup message is not equals to the expected value");

In View Logs HTML Report, it's showing as "Minimum Length of password is 6 And Max Length is 10.\\n". while passing the same string to the HTML page, it's excluding the char "\n".

Ex: "Minimum Length of password is 6 And Max Length is 10."

How can i display the same content("Minimum Length of password is 6 And Max Length is 10.\n") in both View log and in my HTML Report?.

Thanks in Advance.

Thanks & Regards,
Tulasi
Tagged:

Comments

  • narayannarayan Administrators
    You will need to escape the back slash. Otherwise it will get written as a new line.
    You could do something like

    $actualValue = $actualValue.replace(/\\/g, '\\\\');

    before writing it to your file.
  • Hi Narayan,

    I tried with above code what you mentioned. But still it's not displaying as "Minimum Length of password is 6 And Max Length is 10.\n" in my HTML Report.

    Thanks in Advance.

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