예제 #1
0
        public void ActionScenario(string actionName, Action <WebBaseElement> action, LogLevels logSettings)
        {
            _element.LogAction(actionName, logSettings);
            var timer = new Timer();

            new Timer(JDISettings.Timeouts.CurrentTimeoutSec).Wait(() => {
                action(_element);
                return(true);
            });
            JDISettings.Logger.Info(actionName + " done");
            PerformanceStatistic.AddStatistic(timer.TimePassed.TotalMilliseconds);
        }
예제 #2
0
        public void setup()
        {
            Timer _timer = new Timer();

            WebSettings.InitNUnitDefault();
            WinProcUtils.KillAllRunWebDrivers();

            if (!JDISettings.DriverFactory.HasDrivers())
            {
                WebSettings.UseDriver(DriverTypes.Chrome);
            }
            _timer = new Timer();

            WebDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
            WebDriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(5));
            WebDriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(5));

            WebSite.Init(typeof(EbaySite));
            EbaySite.homePage.Open();
        }
예제 #3
0
        public TResult ResultScenario <TResult>(string actionName, Func <WebBaseElement, TResult> action, Func <TResult, string> logResult, LogLevels level)
        {
            _element.LogAction(actionName);
            var timer  = new Timer();
            var result =
                ActionWithException(() => new Timer(JDISettings.Timeouts.CurrentTimeoutSec)
                                    .GetResultByCondition(() => action.Invoke(_element), res => true),
                                    ex => $"Do action {actionName} failed. Can't got result. Reason: {ex}");

            if (result == null)
            {
                throw JDISettings.Exception($"Do action {actionName} failed. Can't got result");
            }
            var stringResult = logResult == null
                    ? result.ToString()
                    : logResult.Invoke(result);

            var timePassed = timer.TimePassed.TotalMilliseconds;

            PerformanceStatistic.AddStatistic(timer.TimePassed.TotalMilliseconds);
            JDISettings.ToLog($"Get result '{stringResult}' in {(timePassed / 1000).ToString("F")} seconds", level);
            return(result);
        }