I am writing a program for automation testing and it works fine. I do however have an issue with the amount of time it takes from the program to start up. This is down to the face that I initialize the IWebdriver = new firefoxDriver() in the public partial class so to allow for all functions to access the driver class with ease and no fuss.
So when i load the program the browser loads which takes maybe 15/20 seconds followed by the GUI I have built. Does anybody know a way of making the "driver" global but not initializing the browser until I call it in a function? i.e. I can load my program and fiddle with the variables etc and then when I am ready I click a button, then the browser loads and executes the function all without have the Iwebdriver = new firefox() in each function separately. Also the reason I have coded it this way (making it global) was due to different browser session issues. It would not see other browsers outside of the initial one on start up
Here is the basic code I am working with
public partial class Main : Form {
IWebDriver driver = new FirefoxDriver();
public Main()
{
InitializeComponent();
}
}
Initialize it the same way but make it static:
Public static IWebDriver Driver;
And then set it to FirefoxDriver where you need it to open the browser:
Driver = new FirefoxDriver();