automated-testsfitnessefitnesse-slimbrowser-testing

Fitnesse Ignore result of method


I am trying to run this fixture code:

|script            |Browser Test                        |
|open              |https://jsfiddle.net/ygjL7hnm/3/show|
|click             |Run this fiddle                     |
|click if available|id=test                             |
|click if available|id=test2                            |
|click if available|id=test3                            |
|click if available|id=test4                            |
|wait              |2              |seconds             |

The problem is I want to ignore the result of "click if available", meaning the test should be all green. I could do that with "reject". That would work perfectly fine but the problem is I don't know which buttons are missing or not missing. So I would have to write "reject" before every "click if available". That results in an error if the button is actually available. As you can see here: enter image description here

But what I want is that no matter if the button is there or not, it should just try to click it and ignore the result of the method. It should not check wether it found the button or not. I hope its clear what I want, if not feel free to ask. Thanks.

Edit: Worth noting I am using this fitnesse version with the HSAC PlugIn.


Solution

  • For slim tests (which in this case, you are using), prepend the script table row with the show keyword. It will just output the function's return value. (true/false in case of 'click if available')

    More info: http://fitnesse.org/FitNesse.UserGuide.WritingAcceptanceTests.SliM.ScriptTable

    From that link:

    The script below should not fail on the execution of click if available:

    |script            |Browser Test                            |
    |open              |https://jsfiddle.net/ygjL7hnm/3/show    |
    |click             |Run this fiddle                         |
    |show              |click if available |this does not exist |