Testing using MBUnit and Selenium

146 views Asked by At

I am trying to build small test case using selenium with MB-Unit Framework. I have written the test case for testing in that am just redirecting to http://www.google.com and searching for "firefox browser".

At the time when am running the test case using Gallio tets runner, test does does not execute. It end up with following error :

enter image description here

and my test case is here :

using MbUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace testfirtsMBUnit
{
  [Parallelizable]
  [TestFixture]
   class grid1
    {
      private IWebDriver driver;
      private StringBuilder verificationErrors;
      private string baseURL;

    [SetUp]
    public void SetupTest()
    {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities = DesiredCapabilities.Firefox();
        capabilities.SetCapability(CapabilityType.BrowserName, "firefox");
        capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows));
        capabilities.SetCapability(CapabilityType.Version, "38.0");

        driver = new RemoteWebDriver(new Uri("http://192.168.1.10:4444/wd/hub"), capabilities);
        baseURL = "https://www.google.co.in/";
        verificationErrors = new StringBuilder();
    }

    [TearDown]
    public void TeardownTest()
    {
        //driver.Quit();
        driver.Quit();
    }

    [Test]
    public void GoogleTest_firefox()
    {
        driver.Navigate().GoToUrl(baseURL + "/");
        driver.FindElement(By.Name("q")).Clear();
        driver.FindElement(By.Name("q")).SendKeys("firefox Browser");
        Thread.Sleep(5000);
    }      
  }
    }

i have run the hub as : enter image description here

and node on remote machine :

enter image description here

I am new to all of this to selenium, to MB-Unit.. Please suggest solution.. let me know am doing something wrong

1

There are 1 answers

0
Chetan Bodke On

I found the solution for this. As i specifies the version of browser from the hub, it is not necessary that node should have browser with same version. So i have removed only that line of code from my SetupTest().

So my SetupTest() is :

public void SetupTest()
{
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities = DesiredCapabilities.Firefox();
    capabilities.SetCapability(CapabilityType.BrowserName, "firefox");
    capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows));
  //   capabilities.SetCapability(CapabilityType.Version, "38.0");// i have removed this line from code

    driver = new RemoteWebDriver(new Uri("http://192.168.1.10:4444/wd/hub"), capabilities);
    baseURL = "https://www.google.co.in/";
    verificationErrors = new StringBuilder();
}