public void ThenSaveScreenshotToXXXX(string fileName) { Regex r = new Regex("(?:[^a-z0-9 ]|(?<=['\"])s)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled); FileInfo fi = new FileInfo(fileName.StrVar()); if (string.IsNullOrEmpty(fi.Name)) { Guid.NewGuid().ToString().Substring(0, 5); } ScreenShot.SaveScreenShot(fi.DirectoryName + "\\" + r.Replace(fi.Name, ""), sDriver); }
public void ThenTakeScreenshotXXXX(string fileName) { string browser = KomodoTestSuite.config.Browser + KomodoTestSuite.config.WindowSize + "_" + KomodoTestSuite.config.Version; FeatureInfo featInfo = FeatureContext.Current.FeatureInfo; ScenarioInfo scenInfo = ScenarioContext.Current.ScenarioInfo; string date = String.Format("{0:yyyyMMdd}", DateTime.Now); string resultsPath = KomodoTestSuite.config.ResultsPath + "\\" + date + "\\" + browser + "\\" + featInfo.Title + "\\" + ScenarioContext.Current.Get <string>("TestId") + "\\"; Regex r = new Regex("(?:[^a-z0-9 ]|(?<=['\"])s)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled); if (fileName == "") { Guid.NewGuid().ToString().Substring(0, 5); } ScreenShot.SaveScreenShot(resultsPath + r.Replace(fileName.StrVar(), ""), sDriver); }
public static void StopSelenium() { Console.WriteLine("Elapsed Total Seconds:" + sw.Elapsed.TotalSeconds); sw.Stop(); //if (driverCache == null) // return; Console.WriteLine("Errors:" + ScenarioContext.Current["selenium-errors"].ToString()); try { //HealthCheckService.InsertSession(oAllSessions, ScenarioContext.Current["TestId"].ToString(), // ScenarioContext.Current.ScenarioInfo.Title, config.Environment); } catch (Exception ex) { Console.WriteLine("Error trying to insert fildder session data" + ex); } try { //ProxyHelper.StopFiddlerProxy(); ScreenShot.SaveScreenShot(Common.ResultsPathDate() + "End_of_test", driverCache); } catch (EntityException entityEx) { Console.WriteLine(entityEx.Message); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Errors:" + ScenarioContext.Current["selenium-errors"].ToString()); //throw; } finally { //Fiddler.FiddlerApplication.Shutdown(); } try { if (driverCache != null) { driverCache.Close(); } } catch (Exception ex) { Debug.WriteLine(ex, "Selenium stop error"); } finally { if (driverCache != null) { driverCache.Quit(); } driverCache = null; } Console.WriteLine("-> Selenium stopped"); }
public void ThenTakeScreenshot() { string fileName = Guid.NewGuid().ToString().Substring(0, 5); ScreenShot.SaveScreenShot(fileName, sDriver); }