Forum Discussion

mng's avatar
mng
Contributor
15 years ago

How to check whether \r\n present?

Hi,

How to create assertion that checking whether \r\n presents?
It seemed I can only see \r\n in the json returned instead of in XML.
How can I do it in json and check whether \r\n exist?

Many thanks!

5 Replies

  • Hello,

    Try adding a Script Asserting containing the following code:


    if(messageExchange.responseContent.contains("\r\n")) {
    assert true
    } else {
    assert false
    }


    Regards,
    Dain
    eviware.com
  • mng's avatar
    mng
    Contributor
    thanks for your information.
    is there any way to check under xml response?

    also, how to do if i have to check whether a new line present before a bullet "•"?
  • mng's avatar
    mng
    Contributor
    mng wrote:
    thanks for your information.
    is there any way to check under xml response?

    also, how to do if i have to check whether a new line present before a bullet "•"?


    any idea for the problem?

    Let say the response is
    "Please bring the following items,

    • Computer"

    How to make assertion of the new line and tab appear before the bullet?
  • Hello,

    Well, for an XML response you could match the content of a specific element against a regular expression perhaps?

    In the Outline view showing the response, right-click the desired element, and select "Add Assertion..." "for Content matching RegEx". When prompted to specify a regular expression to match against, you can use ".*\n.*" (without the quotes) to match some text containing a newline character. The expected result should be "true". The generated expression should be simmilar to this:


    declare namespace sam='http://www.soapui.org/sample/';
    matches( //sam:loginResponse[1]/sessionid[1]/text(), '.*\n.*' )


    Regards,
    Dain
    eviware.com