I have a test method created using Selenium, something similar to this:
[TestFixture]
public class Test_Google
{
IWebDriver driver;
[SetUp]
public void Setup()
{
driver = new InternetExplorerDriver();
}
[TearDown]
public void Teardown()
{
driver.Quit();
}
[Test]
public void TestSearchGoogleForTheAutomatedTester()
{
//Navigate to the site
driver.Navigate().GoToUrl("http://www.google.co.uk");
//Find the Element and create an object so we can use it
IWebElement queryBox = driver.FindElement(By.Name("q"));
//Work with the Element that's on the page
queryBox.SendKeys("The Automated Tester");
queryBox.SendKeys(Keys.ArrowDown);
queryBox.Submit();
//Check that the Title is what we are expecting
Assert.True(driver.Title.IndexOf("The Automated Tester") > -1);
}
}
When the test runs, it opens an IE and carries out its test.
Imagine there are 200 test methods like this spread across multiple test fixtures, which means IE has to be opened and closed many times (as many as test fixtures since 1 browser will be opened per test fixture).
How to run Selenium system tests without requiring to open the browser?
I mean for example I was thinking it might be possible to develop a windows service to run the Selenium tests in the WinForms Web Browser Control, in which case the browser doesn't have to be opened each time and the tests can run automatically and seemlessly. Not sure how to implement this though?
Or is there any other better known way?
Thanks,
No. Selenium is written in JavaScript; it's designed to run in a real browser to test compatibility with a real browser. There are a variety of other tools out there designed to run tests that simulate a browser; you can look into HtmlUnit or Canoo WebTest.
Hope this will help you.