Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Validation of static html files using SOAtest

Options
dgoedh
dgoedh Posts: 63

Hi,
I would like to know what the best way is to validate an html file within SOAtest. It are basically reports stored on my local file system. Here is a snippet:

Deelwaarneming rapportage Normenkader 3.3
ID: 2376
Naam: UWVTest
Start: 16 June 2022 09:33
Status: Verwerkt
Aantal berichten: 1
Aantal volledige berichten: 1 (100.0%)
Aantal juiste berichten: 0 (0.0%)
Loonaangifte: berIdBD = 4320100
AdministratieveEenheid: lhNr = 123456789L07

There are some tags I would like to ignore, like the start date.
What are the best (sequence) of tools for the job? I wish there was a way to convert it to xml, but I am affaid I have to use a text based Diff.
Is there any way to use the webtools (Browser playback etc.) within SOAtest to tackle this?

Thanks in advance.

Have a nice weekend.

Regards,
Daniel

Best Answer

  • jakubiak
    jakubiak Posts: 801 admin
    Answer ✓
    Options

    Your option may be the simplest. I'm not sure why the Browser Validation tool cannot locate the tags - perhaps the DOM rendered by SOAtest is different than Chrome? A relative XPath may work better in that case. Also I'm not sure why HTML Clean Up didn't work - there must be some issue where it cannot parse the specific HTML in your case.

Answers

  • jakubiak
    jakubiak Posts: 801 admin
    Options

    There are two ways you can do this in SOAtest. Here is the easiest way:

    Create a Browser Playback Tool and configure it to navigate to the local file. You would use a URL something like "file:///c:/tmp/report.html". To that playback tool, attach a Browser Validation Tool to validate the contents of the report that you want to validate.

    There is 2nd way to do this that does involve converting it to XML, but it is more steps.
    1. Create a HTML Cleanup Tool. Uncheck "Show informational messages", and change "Target document type" to "XHTML Document (DTD)".
    2. On the Input tab of the HTML Cleanup Tool, select "File" and configure the location of the report.
    3. Right-click on the HTML Cleanup Tool and run "Create/Update Regression Control". The HTML Cleanup Tool by default reports "issues" in the HTML file it is processing, but those issues will fail the test and you don't want that. So the regression control will have the side effect of suppressing reporting of those issues.
    4. Right-click on the HTML Cleanup Tool and choose Add Output. Choose "Transformed Source" on the left and then "XML Assertor" on the right.
    5. Run the HTML Cleanup Tool again to populate information about the HTML file in the XML Assertor tool. Now you can create XML assertions like normal. The only issue here is that it may be hard to find the HTML elements that you want to validate since the HTML file will have lots of presentation tags that you don't care about so you'll have to sift through those. But it will work.

  • dgoedh
    dgoedh Posts: 63
    Options

    Thanks Jakubiak for the swift response. I managed to hook up the Browser Playback Tool with a Browser Validation tool, but somehow SOAtest has troubles locating the tags on the html-report. I have to look into that. I used (full) XPath, derived from Google Chrome inspector.
    The second option with the HTTP Clean Up gave me a warning: Premature End of File. The XML Validator did not detect any XML tags in the Transformed source. The Diff tool (text compare) I also hooked up just detected the html source. But I want to be able to ignore some tags. In XML mode it gives the error: Failed to parse the diff control as XML.
    Maybe I have to opt for a third option: Trimming the html report on the linux, with a sed command, to just keep the lines I want to be validated. Save it as txt-file and do a Diff-text validation on that and done.

    Regards,

    Daniel