Exemple #1
0
 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.");
     }
 }
Exemple #2
0
 public void Close()
 {
     foreach (var driver in RunDrivers)
     {
         driver.Value.Quit();
     }
     RunDrivers.Clear();
 }
Exemple #3
0
 public void ReopenDriver(string driverName)
 {
     if (RunDrivers.ContainsKey(driverName))
     {
         RunDrivers[driverName].Close();
         RunDrivers.Remove(driverName);
     }
     if (Drivers.ContainsKey(driverName))
     {
         GetDriver(); // TODO
     }
 }
Exemple #4
0
 public bool HasRunDrivers()
 {
     return(RunDrivers.Any());
 }