C# – How to run a recorded (HTML) selenium test from .NET


I run Selenium tests with Selenium RC from .NET (c#).

In some cases, I would like to keep the test case source as HTML (to be able to modify it from Selenium IDE), but I would like to run/include these tests from my c# unit tests.

Maybe it is obvious, but I can't find the API method in the Selenium Core to achieve this. Any idea how to do that?

(I think the "includePartial" command in Selenium on Rails does the thing that I would need, but for c#.)

Best Solution

I have asked this question some time ago, and since then I have moved forward in automated functional testing, more to the BDD/ATDD/Specification by Example direction with SpecFlow.

I only realize it now however that I have implemented a solution for this concrete question during my experiments. I share my solution, maybe can help others.

I have created a small parser and an interpreter for the Selenium html files (you can download it from here: http://bit.ly/ciTMA2). Besides the implementation, these classes add some extension methods to the Selenium's ICommandProcessor interface. Base on that, a test can look like this:

List commands = SeParser.ParseSeFile(@"HomePageTest.html"); selenium.Processor.InterpretCommands(commands); selenium.Processor.AssertNoVerifyErrors();

(The InterpretCommands and the AssertNoVerifyErrors are custom extension methods.)