I want to execute a test on three browsers and I want a conditional execution of this test.
Example - If browser name is chrome, go to Google.com and search for selenium testing. If browser name is Firefox, search for MongoDB. This is just a sample code solution but I need to implement this concept in my project.
I'm using TestFixture attribute of Nunit to execute the tests on multiple browsers and I want to continue using NUnit.
Here is the code sample that I'm working with.
Note: You may not see the tests in the Test Explorer because of the search parameters in the Test Fixture attribute.
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Chrome;
using NUnit;
namespace MultipleBrowserTesting
{
[TestFixture(typeof(FirefoxDriver), "MongoDB")]
[TestFixture(typeof(ChromeDriver), "Selenium Testing")]
[TestFixture(typeof(InternetExplorerDriver), "ElasticSearch")]
public class BlogTest<TWebDriver> where TWebDriver : IWebDriver, new()
{
private IWebDriver _driver;
[Test]
public void Can_Visit_Google(string searchString)
{
_driver = new TWebDriver();
// Navigate
_driver.Manage().Window.Maximize();
_driver.Navigate().GoToUrl("http://www.google.ie/");
_driver.FindElement(By.Id("lst-ib")).SendKeys("searchString");
_driver.FindElement(By.Name("btnK")).Click();
FixtureTearDown();
}
[TestFixtureTearDown]
public void FixtureTearDown()
{
// if (_driver != null)
_driver.Close();
}
}
}
I think I'm passing the parameters in a wrong way. I have referred to this link.