Created
April 25, 2012 10:01
-
-
Save deanhume/2488641 to your computer and use it in GitHub Desktop.
Selenium Multiple Browsers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.