1. Download selenium 2 from http://code.google.com/p/selenium/downloads/list i got selenium-dotnet-2.0a6.zip for this exmple
2. Add project references to nunit.framework, webdriver.common and webdriver.IE or webdriver.firefox
3. Using NUnit (No tutorial for that here, google it) create a test class that uses webdriver
using System;
using NUnit.Framework;
using OpenQA.Selenium.IE;
namespace AcceptanceTests
{
[TestFixture]
public class Class1
{
private InternetExplorerDriver _driver;
[TestFixtureSetUp]
public void FixtureSetUp()
{
_driver = new InternetExplorerDriver();
_driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));
}
[TestFixtureTearDown]
public void FixtureTearDown()
{
if (_driver != null) _driver.Close();
}
[Test]
public void GoogleShouldBeInTheTitleWhenNavigatingToGoogleHomePage()
{
//Given
_driver.Navigate().GoToUrl("http://google.co.uk");
//When
//Then
Assert.AreEqual("Google", _driver.Title);
}
}
}
4. Run your tests
5. Done
No comments:
Post a Comment