private void firingDriver_TakeScreenshotOnException(object sender, WebDriverExceptionEventArgs e) { string message = "Exception:- " + DateTime.Now.ToString("yyyy-MM-dd-hhmm-ss"); var screenshot = driver.TakeScreenshot(); Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot(); ss.SaveAsFile(message + ".png", ScreenshotImageFormat.Png); }
//public static bool EmailRecieved() //{ // var api = new WebApiServiceHelper(); // var requestString = string.Format("https://api.mailinator.com/api/inbox?to={0}&token={1}", ScenarioContext.Current["userName"], "7c5b21b2160b42269075e44ff3b7987f"); // return api.Get<MailinatorInbox>(requestString).messages.Count > 0; //} public static string TakeScreenshot() { var timestamp = DateTime.Now.ToString("yyyy-MM-dd-hhmm-ss"); var fileName = "Exception-" + timestamp + ".png"; var firingDriver = new EventFiringWebDriver(driver.WrappedDriver); firingDriver.TakeScreenshot().SaveAsFile(fileName, ImageFormat.Png); return(fileName); }