Clear html from fitnesse tables

382 views Asked by At

How to clean html code from fitnesse table cells?

For example, I've created a table and highlighted a cell as a new one:

|Table: my custom table
|Header1|Header2|
|!style_add[new value]|value|

And when method doTable is called in MyCustomTable class. The second row contain "new value" inside html span tag: <span class="add">new value</span>

What can I do to remove this "span" tag and leave only "new value" for the fixture?

3

There are 3 answers

0
Shoff On BEST ANSWER

Arjan Molenaar wrote me about propriate solution.

For such a problem it is reasonable to create a custom TestSystem based on HtmlSlimTestSystem. You may overwrite processAllTablesOnPage in an order to clear pageToTest.

2
Fried Hoeben On

I'm afraid you'll have to write some Java code in the fixture to parse the and retrieve its text before you actually use it.

E-mail addresses and urls suffer the same problem, they are passed as 'a href="link"' to the fixture. For those I use:

    private static final Pattern PATTERN = Pattern.compile("<a href=\"(.*?)\">(.*?)</a>(.*)", Pattern.CASE_INSENSITIVE);
    protected String cleanupValue(String rawValue) {
        String result = null;
        Matcher matcher = PATTERN.matcher(rawValue);
        if (matcher.matches()) {
            result = matcher.group(2);
        } else {
            result = rawValue;
        }
        return result;
    }
0
Manushin Igor On

Check the attribute ArgumentPrepareAttribute : it allows to cleanup html from input values or provide raw html input.