0

Hi I am new to C# and selenium I am getting error as object reference not set to an instance of an object.My code is

    public LoginPage()
        : base()
    {

        PageFactory.InitElements(Driver, this);
    }

    public LoginPage GoTo()
    {
        Console.WriteLine(ApplicationbaseURL());
        Driver.Navigate().GoToUrl(ApplicationbaseURL());
        try
        {
            if (this.IsCurrentPage() == false)
            {
                throw new WebDriverException("Not on correct Page");

            }
        }
        catch (WebDriverException ex)
        {
            Console.WriteLine("Exception caught: {0}", ex);
        }
        return this;
    }

1 Answers1

0

Make sure that you don't use destructor in your base class! If you have destructor in your base class it could be invoked whenever, so you get no driver present.

Denis Koreyba
  • 3,144
  • 1
  • 31
  • 49