Get your webtests in FitNesse with Xebium

Arjan Molenaar

In the first installment on Xebium, Cirilo explained the ideas behind this FitNesse fixture:


Xebium creates a simple way to use Selenium IDE (low learning curve) and FitNesse (ease of maintenance) to it's fullest when it comes to maintaining a web application test suites.

Xebium is using the same keywords as Selenium IDE. This has the huge advantage that no person should learn another DSL. Since tests are stated this way, they can be copied between Selenium IDE and FitNesse without a hassle (the FitNesse formatter for Selenium IDE is rather trivial). And to be honest: as long as there are XPath and Regular Expressions in the code, it makes no sense to come up with a substitute for verifyText.

Copy test output directly in SeIDE

So now it is possible to move our Selenium IDE test case in a FitNesse page. Nice. It's easier to set up tests, since FitNesse is quite flexible in that. On the other hand, just playing back you recorded tests is not the most flexible way to work. There can be a huge maintenance burden on this. It would be a shame not to use the full power of FitNesse in this case. Scenario tables for example can make a nice abstraction where some common action, like logging in, only have to be defined (and maintained) in one place. By moving the login code out of the test and into a scenario, we add another level of indirection. The tests themselves become more readable, as they only state the business requirement and the low level details are directly editable by the tester. This is a lot more flexible than creating Selenium fixtures for every scenario.

| log in user | user | with password | password |
| open | http://example.com/login |
| type | name-field | @user |
| type | password-field | @password |
| click | login |

and in your tests, instead of repeating the above, just mention:

| script |
| log in user | john | with password | secret |
| ensure | do | verifyText | on | #userid | with | John |

Sure, we're back at creating our own DSL, but we do it 100% in FitNesse. Selenium commands can be added where needed (e.g. assertions). No Java (fixture) code, no developers required to change one line because the templates have changed and, foremost, detailed feedback.

But FitNesse can help out even more. Consider data driven testing. Selenium has (by default) no option for that. Using the same scenario table fixture it's easy to test logins for a bunch of users.

But we claimed you can copy stuff from FitNesse to Selenium IDE as well and that's getting harder when you move everything inro scenarios. To overcome this issue the formatter in Selenium IDE can parse tab separated data as well. So after a test has run, the output as provided by FitNesse can be copied back. This is a useful aid for analyzing failed tests.

Copy tests from SeIDE to FitNesse

I tend to make my Xebium commands easely available. First of all the fixture needs to be imported. After that the fixture can be assigned as library:

| import |
| com.xebia.incubator.xebium |

| library |
| selenium driver fixture |

A note for Windows users, though. When performing a lot of tests, Windows tends to run out of sockets. There is a way to configure your machine to work around those silly limitations (at your own risk!).

Comments (15)

  1. Stewart - Reply

    February 8, 2012 at 1:49 pm

    Hi There,

    A point to out for is that if you have a '|' in some text, such as in the page title, this needs to be converted to wiki syntax '!-|-!' in order for FitNesse not to interpret it as a table column separator.
    It would be a really nice touch if the Xebium formatter plugin for Selenium IDE did this automatically.
    See this URL for more info: http://old.nabble.com/escape-|-%28vertical-bar%29-in-fitnesse-wiki-td22298159.html

    Thanks!

  2. Arjan Molenaar - Reply

    February 8, 2012 at 1:59 pm

    Hi,

    Thanks for the remark. I filed it as a bug: https://github.com/xebia/Xebium/issues/40.

    Regards,
    Arjan

  3. Stewart - Reply

    March 14, 2012 at 4:35 pm

    Hi Again,

    Is the syntax purely limited to what Selenium IDE can provide?
    I've been using this reference: http://seleniumhq.org/docs/02_selenium_ide.html

    Two areas I've been having trouble with, in the context of testing a webapp is not vulnerable to XSS, is (1) verifying javascript alerts, (2) verifying an absence of somthing, perhaps something like | ensure | not | verifyText | on | #userid | with | John |

    Do you have any tips for this situation?

    Regards,

    Stewart

    PS. Is there a good Xebium forum to use, for this kind of stuff?

  4. Arjan Molenaar - Reply

    March 14, 2012 at 10:52 pm

    Hi,

    You're right, all commands that are available in Selenium IDE can be executed by Xebium.

    Regarding your question, you can so something like
    | reject | do | verifyText | on |#userid | with | John |
    (instead of ensure, use reject). This does not translate back as well when copying tests from FitNesse to SeleniumIDE, but it's the easiest way.

    Regards,

    Arjan

    • Jan Helwich - Reply

      March 15, 2012 at 4:24 pm

      Hi!

      We are having troubles getting the copying back working. It doesn't work on Win and Linux as well and also not with the examples given in the template.

      Any idea why? Any trick to use or thing we must do?

      Thanks and best regards
      Jan

    • Stewart - Reply

      March 16, 2012 at 5:03 pm

      That's excellent. I can test XSS vulnerability with | reject | do | verifyElementPresent | on | //div[@id='id']/ul/li/script | to make sure that a tag has not been rendered, but escaped.

  5. Arjan Molenaar - Reply

    March 16, 2012 at 12:44 pm

    Hi Jan,

    I think I need a little more detail in order to help you out. We can discuss this at the Xebium ML (mailto:xebium@googlegroups.com).

    Regards,

    Arjan

  6. Rajendra - Reply

    May 4, 2012 at 12:52 pm

    Hi,
    Is there any way to record and run the double click functionality using Xebium? Please share it.
    As our project requirement is to have a test script for double click functionality, which cannot be achieved using Xebium. But Selenium supports the double click functionality.

    Thanks in Advance,

    Waiting for your reply,
    Rajendra

  7. Rajendra - Reply

    May 6, 2012 at 8:00 pm

    HI,
    I could not execute the double click functionality using Xebium test scripts.
    Can anybody help me out?

    Thanks in advance,
    Rajendra

  8. Phalguni - Reply

    May 23, 2012 at 5:21 pm

    How can we handle double click in xebium.

  9. Rahul - Reply

    June 8, 2012 at 6:47 am

    Hi,

    Is there a forum to post issues such as installation issues for Xebium? I can't seem to find such a thing. I am having trouble running the mvn -Pfitnesse test command, for installation. Any advice would be appreciated on places to go for help.

    Thanks,
    Rahul

  10. Arjan Molenaar - Reply

    June 8, 2012 at 9:23 am

    Hi,

    @Phalguni: If Selenium IDE supports doubleClick, Xebium will as well. Xebium is using a Selenium integration layer on top of WebDriver. This integration layer supports all Selenese commands as they are used by Selenium IDE.

    | ensure | do | doubleClick | on | myElement |

    should do the trick.

    There is a mailing list, xebium@googlegroups.com, where you can post issues or discuss features.

  11. Karanbir - Reply

    February 12, 2013 at 1:05 pm

    Hi,

    I am new to xebium and need help to figure out , How to compare 2 values in Xebium.

    Thanks in advance

    Regards
    Karan

  12. Guillermo Schwarz - Reply

    August 9, 2013 at 5:15 pm

    "A note for Windows users, though. When performing a lot of tests, Windows tends to run out of sockets. There is a way to configure your machine to work around those silly limitations (at your own risk!)."

    That's a clear symptom that Xebium has resource leaks.

  13. abhishek koulgi - Reply

    June 22, 2016 at 11:11 pm

    Hi,
    I am new to xebium and i copied exported the test case from selenuim to fitnesse as required but i am getting" Could not invoke constructor for SeleniumDriverFixture[0]" and "The instance scriptTableActor.doOn. does not exist" after i tried to run simple test from the link:https://blogs.infosupport.com/my-first-xebium-fitnesse-selenium-test/,please help me in this .do I need to add some libraries or set particular path?
    thank you

Add a Comment