Example #1
0
        public void MyScenarioCleanup()
        {
            try
            {
                // Clean up all connections and generate report
                var testFinalStatus = CheckTestCaseStatus();
                var message         = EnvironmentVariableHelper.GetBddStepDescription() +
                                      TestContext.CurrentContext.Result.Message;

                var stackTrace = TestContext.CurrentContext.Result.StackTrace;

                TestCaseProvider.Instance
                .LogTestCaseFinalStatus(testFinalStatus, message, stackTrace,
                                        TestCaseInfo.TestCaseFullName, TestCaseInfo.TestCaseName);

                BaseTestManagerClass.MyTestCleanupClose();
                ProcessManager.KillProcess("chrome");
            }
            catch (Exception e)
            {
                // Clean up all connections and generate report
                BaseTestManagerClass.MyTestCleanupClose();

                //Kill chrome driver
                ProcessManager.KillProcess("chromedriver");
                ProcessManager.KillProcess("chrome");

                ExceptionManager.WarningMessageLog(e.Message);
            }
        }
Example #2
0
        public void FindElement()
        {
            Func <IWebElement> firstAttempt = () =>
            {
                return(SeleniumActions.GetWaitDriver.Until(d => d.FindElement(_locator)));
            };

            Func <IWebElement> secondAttempt = () =>
            {
                return(SeleniumActions.GetWaitDriver.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(_locator)));
            };

            string      errorMessage;
            IWebElement element;

            if (TryFindElement(new[] { firstAttempt, secondAttempt }, out element, out errorMessage))
            {
                _seleniumElement = element;
            }
            else
            {
                _seleniumElement = null;

                //Log
                string message = string.Format("Unable to find the following element: [ {0} ] [ {1} ]. [ {2} ].",
                                               _locator, _controlName, errorMessage);
                LoggerManagerClass.Instance.Error(EnvironmentVariableHelper.GetBddStepDescription() + message);
                TestCaseProvider.Instance.AddStepInCurrentTestCase(LogStepStatus.Failed, message);
                throw new NoSuchElementException(message);
            }
        }