Skip to content

Instantly share code, notes, and snippets.

@deanhume
Created April 25, 2012 10:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save deanhume/2488641 to your computer and use it in GitHub Desktop.
Save deanhume/2488641 to your computer and use it in GitHub Desktop.
Selenium Multiple Browsers
namespace SeleniumTest
{
[TestFixture(typeof(FirefoxDriver))]
[TestFixture(typeof(InternetExplorerDriver))]
public class BlogTest<TWebDriver> where TWebDriver : IWebDriver, new()
{
private IWebDriver _driver;
[Test]
public void SearchResults_ShouldHaveCorrectPageTitle()
{
_driver = new TWebDriver();
// Navigate
_driver.Navigate().GoToUrl("http://www.deanhume.com");
IWebElement searchBox = _driver.FindElement(By.Name("searchValue"));
searchBox.SendKeys("moq");
searchBox.Submit();
Assert.AreEqual("Dean Hume - Search Results - moq", _driver.Title);
}
[TestFixtureTearDown]
public void FixtureTearDown()
{
if (_driver != null) _driver.Close();
}
}
}
@michaelhidalgo
Copy link

Good stuff, The problem with this approach is that the driver is created per each Test which is expensive. I created a base class and I was able to create the driver per Test case rather than creating it per single test.

I wonder if there is a way to create the driver and reuse it during all the execution, it would be faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment