Testing the web - a new hope

By eidias on (tags: fluent, testing, categories: tools, web)

There are plenty of ways to test web apps, but most of them require a cumbersome setup and a lot of tools installed and I’m just too lazy to do that. But I just found something that may work in my favour.

The fact that I will need something more than unit tests for web apps is obvious – I just didn’t have the time/urge/heart to set up ‘the whole machine’. I’ve had some experience in the past with automated web testing tools. They were big, heavy, expensive and reliability was an issue. Then came selenium – not expensive (well, free – it’s as cheep as it gets), but if it’s heavy or not – to be honest I don’t know. I know selenium only from the theoretical perspective – no practice whatsoever.

But recently I stumbled upon Fluent. It comes in 2 nuget packages FluentAutomation.Core and FluentAutomation.SeleniumWebDriver. There’s also a third one – WatiN but I haven’t checked it yet and I don’t think I will – the docs say that selenium driver is the recommended way – I’ll just stick with that.

To get started – just install the SeleniumWebDriver package, create a unit test project and use this code:

   1: using FluentAutomation;
   2: using Microsoft.VisualStudio.TestTools.UnitTesting;
   3:  
   4: namespace UnitTestProject1
   5: {
   6:     [TestClass]
   7:     public class UnitTest1 : FluentTest
   8:     {
   9:         public UnitTest1()
  10:         {
  11:             SeleniumWebDriver.Bootstrap(SeleniumWebDriver.Browser.Firefox);
  12:         }
  13:  
  14:         [TestMethod]
  15:         public void TestMethod1()
  16:         {
  17:             I.Open("http://localhost:62272/")
  18:              .Enter("Lorem ipsum").In("input[type=\"text\"]")
  19:              .Click("input[type=\"submit\"]")
  20:              .Expect
  21:              .Url(u => u.Query.Contains("?foo=Lorem+ipsum"));
  22:         }
  23:     }
  24: }

No heavy installs, everything comes in nugets and the API is well, poetic Winking smile.

I’m keeping my fingers crossed that there won’t be too many problems when trying to run this on the build server, though my gut tells me that I’ll struggle a bit. One thing’s for sure, I’ll need to use the IE driver.

Cheers