public IWebDriver GetDriver(string driverName) { if (!Drivers.ContainsKey(driverName)) { throw new Exception($"Can't find driver with name {driverName}"); } try { if (RunDrivers.ContainsKey(driverName)) { return(RunDrivers[driverName]); } var resultDriver = Drivers[driverName].Invoke(); RunDrivers.Add(driverName, resultDriver); if (resultDriver == null) { throw new Exception($"Can't get Webdriver {driverName}. This Driver name not registered"); } return(resultDriver); } catch { throw new Exception("Can't get driver."); } }
public void Close() { foreach (var driver in RunDrivers) { driver.Value.Quit(); } RunDrivers.Clear(); }
public void ReopenDriver(string driverName) { if (RunDrivers.ContainsKey(driverName)) { RunDrivers[driverName].Close(); RunDrivers.Remove(driverName); } if (Drivers.ContainsKey(driverName)) { GetDriver(); // TODO } }
public bool HasRunDrivers() { return(RunDrivers.Any()); }