Browser Factory or WebDriver Factory Tutorial
Near the end of the Browser Factory or WebDriver Factory Tutorial (http://toolsqa.com/selenium-webdriver/c-sharp/browser-factory-or-webdriver-factory/), there is a code block titled “LogInTest TestCase”. Inside that code snippet there is a variable named “driver” used and I don’t see where it is coming from? There is no BaseTest it is inherited from? What am I missing?
I’m trying to implement the BrowserFactory and PageFactory patterns, but I’m not sure where the IWebDriver should come from that is passed into the Page constructor.
@crusaderDave, I believe the missing item is this (at least this is what I have added and it means the tests run as expected).
var driver = WebDriverFactory.Driver;
This will then give you the reference to the driver. Hope that helps
or, later on, if you review the page-generator walkthrough – then driver becomes obsolete in the tests
Forgive me if it is incorrect to ask follow up questions, but I have a problem with this tutorial as well.
Whenever I run the logintest I am always presented with the exception (“The WebDriver browser instance was not initialized”)…
LoginTest calls InitBrowser, which checks if Driver is Null – Attempts to get Driver which checks if _driver is Null, which it always will be… and then throws the exception. Have I misunderstood, or is there an error in the tutorial?