Loading ...
Sorry, an error occurred while loading the content.
 

How to test a returned string which contains html ?‏

Expand Messages
  • spikeybill66
    Hello, using slim, we have a generic fixture CheckTag which tests values from a file containing key value pairs. Some of the values are actually html (as
    Message 1 of 4 , May 1, 2013
      Hello,

      using slim, we have a generic fixture CheckTag which tests values from a file containing key value pairs.
      Some of the values are actually html (as demonstrated below, where i have defined a variable containing the expected link).
      How can I get FitNesse to 'escape' the html so that it can be compared to the ${link} variable rather than be rendered ?



      !define link {<img src="http://somedomain.com/SomePage.aspx?id=" width='2' height='2'>}

      |Check Tag|c:\somefile_containing_key_value_pairs.txt|
      |Key |Value? |
      |EMAIL_TRACKING_LINK |${link}|
      |FIRSTNAME |Mike |
      |LASTNAME |Smith |




      public class CheckTag
      {
      private readonly string filePath;

      public string Key;

      public CheckTag(string filePath)
      {
      this.filePath = filePath;
      }

      public string Value()
      {
      return FileProcessor.ExtractValue(filePath, Key);
      }
      }


      thanks.
    • Stanimir Stamenkov
      Wed, 01 May 2013 13:49:40 -0000, spikeybill66 : using slim, we have a generic fixture CheckTag which tests values from a file containing key value pairs. Some
      Message 2 of 4 , May 7, 2013
        Wed, 01 May 2013 13:49:40 -0000, spikeybill66:

        using slim, we have a generic fixture CheckTag which tests values from a file containing key value pairs.
        Some of the values are actually html (as demonstrated below, where i have defined a variable containing the expected link).
        How can I get FitNesse to 'escape' the html so that it can be compared to the ${link} variable rather than be rendered ?

        !define link {<img src="http://somedomain.com/SomePage.aspx?id=" width='2' height='2'>}
        
        |Check Tag|c:\somefile_containing_key_value_pairs.txt|
        |Key |Value? |
        |EMAIL_TRACKING_LINK |${link}|
        |FIRSTNAME |Mike |
        |LASTNAME |Smith |
        

        Which version of FitNesse are you using?  Is it any different using latest Edge build? (https://cleancoder.ci.cloudbees.com/job/fitnesse/lastStableBuild/)

        I think your problem is related to the fact the URL value in the 'src' attribute is automatically translated to a link, therefore the actual value asserted in the test becomes:

        <img src="<a href="http://somedomain.com/SomePage.aspx?id="">http://somedomain.com/SomePage.aspx?id="</a>width='2' height='2'>

        Try prepending your table with an ! (apostrophe) to markup a literal table inside which no Wiki markup is interpreted/translated:

        http://fitnesse.org/FitNesse.UserGuide.MarkupTable

        !|Check Tag|c:\somefile_containing_key_value_pairs.txt|

        Alternatively you may markup the variable value as a literaltext, between !- -!:

        http://fitnesse.org/FitNesse.UserGuide.MarkupLiteralText

        !define link {!-<img src="http://somedomain.com/SomePage.aspx?id=" width='2' height='2'>-!}
        

        But when rendering the page normally, the literal text is inserted as raw source (HTML) and in your case you may get confused if you see an empty cell, until you run the test and get the result.

        -- Stanimir

      • Stanimir Stamenkov
        Wed, 08 May 2013 00:16:06 +0300, Stanimir Stamenkov : Alternatively you may markup the variable value as a literal text , between !- -! :
        Message 3 of 4 , May 7, 2013
          Wed, 08 May 2013 00:16:06 +0300, StanimirStamenkov:

          Alternatively you may markup the variable value as a literaltext, between !- -!:

          http://fitnesse.org/FitNesse.UserGuide.MarkupLiteralText

          !define link {!-<img src="http://somedomain.com/SomePage.aspx?id=" width='2' height='2'>-!}
          

          But when rendering the page normally, the literal text is inserted as raw source (HTML) and in your case you may get confused if you see an empty cell, until you run the test and get the result.

          Yet another approach would be to markup only the part of the value, which causes it to be interpreted specially, as literal text:

          !define link {<img src="!-http:-!//somedomain.com/SomePage.aspx?id=" width='2' height='2'>}
          

          But probably the literal table solution is best and most convenient.

          -- Stanimir

        • spikeybill66
          thankyou for the reply. We are using v20110104. the immediate requirement has now gone away but i ll try what you have suggested...thanks
          Message 4 of 4 , May 8, 2013
            thankyou for the reply. We are using v20110104. the immediate requirement has now gone away but i'll try what you have suggested...thanks
          Your message has been successfully submitted and would be delivered to recipients shortly.