2

I want to initialize my WebDriver property that in my test class and when I want to use it in the scenario it is 'Null'.

In the example here, when I try to navigate to some url I get null exception.

Example:

[BeforeScenario]
    private void BeforeScenario()
    {
        TestInitilaize();
    }

[TestInitialize]
    public void TestInitilaize()
    {
        InitializeTest();
    }

protected virtual void InitializeTest()
    {
        WebDriver = new FirefoxDriver();
    }

[Given(@"Some Given")]
    public void GivenMethod()
    {
        WebDriver.Navigate().GoToUrl("www.someurl.com");
    }
Udiy
  • 65
  • 2

1 Answers1

0

The problem is probably that your [BeforeScenario] method is private. Have you checked that the method is actually called in the debugger?

Sam Holder
  • 32,535
  • 13
  • 101
  • 181
  • Yes, the debugger is calling the method. – Udiy Dec 08 '14 at 11:24
  • you were right, because it was private it was called but I think because I have an inheritance it worked for the base class, when I changed it to public the [BeforeScenario] been called twice but the value saved and I could use it in my specflow's steps. – Udiy Dec 08 '14 at 15:13