public void Dispose() { if (_driver != null) { _driver.Dispose(); _driver = null; } }
/// <summary> /// Closes the driver. /// </summary> public void CloseDriver() { switch (webBrowser) { case WebBrowser.Android: androidWebDriver?.Quit(); androidWebDriver?.Dispose(); androidWebDriver = null; break; case WebBrowser.Chrome: chromeWebDriver.Quit(); chromeWebDriver.Dispose(); chromeWebDriver = null; break; } }
public void Dispose() { _driver.Dispose(); }
public void TestCleanup() { _driver?.CloseApp(); _driver?.Quit(); _driver?.Dispose(); }
public void CleanUp() => driver.Dispose();
public static void AndroidCleanUp() { androidDriver.Dispose(); }
private void Init(string type) { switch (_name) { case "android": string apkFile = TestingDossier.LocalAPPFolder + TestingDossier.APPFileName; DesiredCapabilities Capabilities = new DesiredCapabilities(); Capabilities.SetCapability(MobileCapabilityType.DeviceName, TestingDossier.AndroidDeviceName); if (System.IO.File.Exists(apkFile)) { Capabilities.SetCapability(MobileCapabilityType.App, apkFile); } else { Capabilities.SetCapability(AndroidMobileCapabilityType.AppPackage, TestingDossier.AndroidAppPackage); Capabilities.SetCapability(AndroidMobileCapabilityType.AppActivity, TestingDossier.AndroidAppActivity); } //Must init twice when application file is not null. //first time is remove all data of the application, install new version. //Second time, init the application with config noreset=true, then the application will restore the login information if (type.Equals("FirstInit") && System.IO.File.Exists(apkFile)) { for (int initTimes = 1; initTimes <= 2; initTimes++) { if (initTimes == 1) { //will uninstall the app then install it again. Capabilities.SetCapability("fullReset", true); } else { //will keep the login and other information Capabilities.SetCapability("fullReset", false); Capabilities.SetCapability("noReset", true); } _driver = new AndroidDriver <IWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), Capabilities); //first time is remove all data of the application. if (initTimes == 1) { _driver.Dispose(); _driver = null; } else { //_driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); _javaScript = (IJavaScriptExecutor)_driver; //set the driver for screen shot Executor.Driver = _driver; } } } else { _driver = new AndroidDriver <IWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), Capabilities); _javaScript = (IJavaScriptExecutor)_driver; //set the driver for screen shot Executor.Driver = _driver; } //Restart the application if test case error, make sure next test case can continue. but not remove the data of the application, need store the login and other information //if first init application, do not remove all data when there is not application file. //if (type.Equals("RestartApp") || // (type.Equals("FirstInit") && !System.IO.File.Exists(apkFile))) //{ // Capabilities.SetCapability("appWaitActivity", TestingDossier.AndroidAppWaitActivity); // //will keep the login and other information // Capabilities.SetCapability("fullReset", false); // Capabilities.SetCapability("noReset", true); // _driver = new AndroidDriver<IWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), Capabilities); // _driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); // _javaScript = (IJavaScriptExecutor)_driver; // //set the driver for screen shot // Executor.Driver = _driver; //} break; default: throw new ArgumentException("Unknown driver: " + _name); } }
public static void CleanUp() { _driverInstance.Dispose(); _driverInstance = null; cap = null; }
/// <summary> /// Closes the driver. /// </summary> public void CloseDriver() { androidDriver?.Quit(); androidDriver?.Dispose(); androidDriver = null; }