I am working in C# with Selenium Grid2 and MbUnit/Gallio. I read that a combination of datasets can be used to drive MbUnit UsingFactories alternative in MbUnit v3. So, I am trying to use MbUnit to have a single Test executed on multiple browsers with an additional dataset to make the cartesian product of browsers and data into tests. If I run the code without the extra data set things work fine, the test code is executed against the two browsers.
private IEnumerable<ICapabilities> ProvideCapabilities
{
get
{
yield return DesiredCapabilities.Firefox();
yield return DesiredCapabilities.Chrome();
}
}
[Test]
public void testBrowser([Factory("ProvideCapabilities")] ICapabilities browser)
{
IWebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),
browser);
driver.Navigate().GoToUrl("http://www.google.com/");
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Bark");
query.Submit();
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until((d) => { return d.Title.ToLower().StartsWith("bark"); });
System.Console.WriteLine("Page title is: " + driver.Title);
driver.Quit();
System.Console.WriteLine("end of testBrowser");
}
If I add in the dataset to make the testcase data driven Selenium times out, but the actions have been run against browsers correctly. It seems like the grid just never receives the result from the node. In the MbUnit testrunner Icarus I see four tests have been ran but timeout. The code is creating a new WebDriver object with each execution but could there be some other shared resource in Selenium Grid2 that is preventing this from working.
private IEnumerable<ICapabilities> ProvideCapabilities
{
get
{
yield return DesiredCapabilities.Firefox();
yield return DesiredCapabilities.Chrome();
}
}
public IEnumerable<string> ProvideSearchString
{
get
{
yield return "Cheese";
yield return "Bark";
}
}
[Test]
public void testBrowser([Factory("ProvideCapabilities")] ICapabilities browser, [Factory("ProvideSearchString")] string searchString)
{
IWebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),
browser);
driver.Navigate().GoToUrl("http://www.google.com/");
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys(searchString);
query.Submit();
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until((d) => { return d.Title.ToLower().StartsWith(searchString); });
System.Console.WriteLine("Page title is: " + driver.Title);
driver.Quit();
System.Console.WriteLine("end of testBrowser");
}