Friday 25 November 2011

Different setup fixtures for different browsers in selenium webdriver using NUnit Framework

 public abstract class testwithMultiBrowser
    {
        protected IWebDriver driver;
        [Test]
        public void test()
        {
            driver.Navigate().GoToUrl("http://google.co.in");
        }
    }
  [TestFixture]
  class testwithFirefox:testwithMultiBrowser
    {
      [SetUp]
      public void firefoxSetup()
      {
          driver = new FirefoxDriver();
          IWindow window = driver.Manage().Window;
          window.Size = new Size(1366, 768);
      }
      [TearDown]
      public void tearDown()
      {
          driver.Quit();
      }
    }
    [TestFixture]
    class testwithIE:testwithMultiBrowser
    {
      [SetUp]
      public void iesetUP()
      {
          driver = new InternetExplorerDriver();
      }
      [TearDown]
      public void tearDown()
      {
          driver.Quit();
      }
 }

No comments:

Post a Comment