I\'m looking for the recommended/nicest way to make Selenium tests execute in several browsers one after another. The website I\'m testing isn\'t big, so I don\'t need a par
This is a recurring question and is solved a couple ways:
Factory method produces your ISelenium object - You have a helper class with a static getSelenium method. That method reads in some external config, which has a property that defines the browser you want as a string. In your getSelenium you then configure the browser accordingly. here's a handy post on using config files with NUnit http://blog.coryfoy.com/2005/08/nunit-app-config-files-its-all-about-the-nunit-file/
Others have success with injecting the browser via an IoC container. I really like this because TestNG works really well with Guice in Java land, but I'm not sure how easy it is to mix NUnit and Ninject, MEF, etc...
Ok, one solution is to have wrapper tests that set-up the ISelenium object with different browsers. Then they pass that object to all the other tests which use it instead of setting up a new one themselves like they did previously.
The disadvantage is, I end up with one big test for each browser. Not the best solution either. Still looking...
EDIT:
Spent some more time on this. The solution I came up with is to have a text file in the solution that specifies the browser to use for testing. NUnit picks up the setting when instantiating a Selenium object.
I'm using CruiseControl.NET to run automatic builds and tests. And instead of just running the test once, I configured it to run them twice. But before each test I run a command line command that changes the browser in the configuration text file.
<exec>
<executable>cmd</executable>
<buildArgs>/C echo firefox C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe > F:\...\selenium_browser.txt</buildArgs>
</exec>
<exec>
<executable>F:\...\NUnit 2.5.7\bin\net-2.0\nunit-console.exe</executable>
<baseDirectory>F:\...\bin\Debug</baseDirectory>
<buildArgs>F:\...\...nunit /xml:"F:\CCXmlLog\Project\nunit-results.xml" /noshadow</buildArgs>
<successExitCodes>0</successExitCodes>
<buildTimeoutSeconds>1200</buildTimeoutSeconds>
</exec>
<exec>
<executable>cmd</executable>
<buildArgs>/C echo googlechrome C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe > F:\...\selenium_browser.txt</buildArgs>
</exec>
<exec>
<executable>F:\...\NUnit 2.5.7\bin\net-2.0\nunit-console.exe</executable>
<baseDirectory>F:\...\bin\Debug</baseDirectory>
<buildArgs>F:\...\...nunit /xml:"F:\CCXmlLog\Project\nunit-results.xml" /noshadow</buildArgs>
<successExitCodes>0</successExitCodes>
<buildTimeoutSeconds>1200</buildTimeoutSeconds>
</exec>