public void GiventParentAndChildStaleElement_WhenFirstCallToThatElementIsMade_ShouldNotThrowStaleElementReferenceException()
        {
            WebElement soonToBeStaleParentElement = null;
            WebElement soonToBeStaleChildElement  = null;

            TestSteps
            .GoTo <ExamplesPage>((page, a) =>
            {
                soonToBeStaleParentElement = page.Form;
                soonToBeStaleChildElement  = page.FirstInputElement;
            })
            .GoTo <ExamplesPage>((page, a) =>
            {
                Assert.Multiple(() =>
                {
                    Assert.That(soonToBeStaleParentElement.IsStale, Is.False, "Parent is not stale, as it was not cached yet (lazy loading).");
                    Assert.That(soonToBeStaleChildElement.IsStale, Is.False, "Child element is not stale, as it was not loaded yet (lazy loading).");

                    Assert.That(() => MakeACallTo(soonToBeStaleChildElement),
                                Throws.Nothing,
                                $"Should not throw {typeof(StaleElementReferenceException)} neither on parent element, nor on child element.");
                    Assert.That(soonToBeStaleParentElement.IsStale, Is.False, "Parent should not be staled. Nothing has changed.");
                    Assert.That(soonToBeStaleChildElement.IsStale, Is.False, "Child element should not be staled. Nothing has changed.");
                });
            });
        }
예제 #2
0
        public IServiceTestStep AddTestStep(string activityUniqueId, string activityDisplayName, string activityTypeName, ObservableCollection <IServiceTestOutput> serviceTestOutputs, StepType stepType)
        {
            if (string.IsNullOrEmpty(activityUniqueId))
            {
                throw new ArgumentNullException(nameof(activityUniqueId));
            }

            if (string.IsNullOrEmpty(activityTypeName))
            {
                throw new ArgumentNullException(nameof(activityTypeName));
            }

            if (serviceTestOutputs == null)
            {
                throw new ArgumentNullException(nameof(serviceTestOutputs));
            }

            var testStep = new ServiceTestStep(Guid.Parse(activityUniqueId), activityTypeName, serviceTestOutputs, stepType)
            {
                StepDescription = activityDisplayName
            };

            TestSteps.Add(testStep);
            return(testStep);
        }
예제 #3
0
 private void ResetTest()
 {
     TestComment = string.Empty;
     TestSteps.Clear();
     foreach (var ts in Map(_execution.Steps))
     {
         TestSteps.Add(ts);
     }
 }
예제 #4
0
 void _execution_OnRunCompleted(object sender, TestRunCompletedEventArgs args)
 {
     Statistics.StopTestTimer();
     Statistics.UpdateAverageTime();
     Statistics.UnitsTested++;
     Statistics.UpdatePassRate(!TestSteps.Where(t => t.StepStatus == TestStepStatus.FAILED).Any());
     Statistics.SerialNumber = args.SerialNumber;
     Statistics.UserData     = args.UnitData;
     _currentState           = TestExecutionState.ENDED;
     ButtonText = "RESET";
 }
예제 #5
0
 private void TestPlanListView_DbClick(object sender, EventArgs e)
 {
     tabControl2.SelectTab(0);
     TestSteps.Clear();
     foreach (string file in fileList)
     {
         string fileName = TestPlanListView.SelectedItems[0].SubItems[2].Text + ".lua";
         if (file.ToLower().Contains(fileName.Trim().ToLower()))
         {
             ParseLuaTestCases(file);
         }
     }
 }
예제 #6
0
 private void TestPlanList_DoubleClick(object sender, EventArgs e)
 {
     tabControl2.SelectTab(0);
     TestSteps.Clear();
     foreach (string file in fileList)
     {
         string fileName = TestPlanList.SelectedItem.ToString().Substring(TestPlanList.SelectedItem.ToString().IndexOf(' ')) + ".lua";
         if (file.ToLower().Contains(fileName.Trim().ToLower()))
         {
             ParseLuaTestCases(file);
         }
     }
 }
예제 #7
0
        public void GivenNotCachedElement_WhenFirstCallToElementIsMade_ShouldCacheElement()
        {
            TestSteps
            .GoTo <ExamplesPage>((page, a) =>
            {
                Assert.Multiple(() =>
                {
                    var parentElement = page.Form;

                    Assert.That(parentElement.IsCached, Is.False, "Should not be cached");

                    TriggerCachingMechanismOn(parentElement);
                    Assert.That(page.Form.IsCached, Is.True, "Should be cached");
                });
            });
        }
예제 #8
0
        public void GivenNotCachedParentAndChildElement_WhenFirstCallToChildElementIsMade_ShouldCacheBothElements()
        {
            TestSteps
            .GoTo <ExamplesPage>((page, a) =>
            {
                Assert.Multiple(() =>
                {
                    var parentElement = page.Form;
                    var childElement  = page.FirstInputElement;

                    Assert.That(parentElement.IsCached, Is.False, "Parent should not be cached");
                    Assert.That(childElement.IsCached, Is.False, "Child element should not be cached");

                    TriggerCachingMechanismOn(childElement);
                    Assert.That(page.Form.IsCached, Is.True, "Parent should be cached.");
                    Assert.That(page.FirstInputElement.IsCached, Is.True, "Parent should be cached.");
                });
            });
        }
예제 #9
0
 private void ParseLuaTestCases(string file)
 {
     TestSteps.Clear();
     string[] lines = File.ReadAllLines(file, Encoding.Default);
     foreach (string str in lines)
     {
         if (str.Contains("--"))
         {
             TestSteps.SelectionColor = Color.Green;
         }
         else if (str.Contains("TestCaseBegin") || str.Contains("TestCaseEnd"))
         {
             TestSteps.SelectionColor = Color.Blue;
         }
         else
         {
             TestSteps.SelectionColor = Color.Black;
         }
         TestSteps.AppendText(str);
         TestSteps.AppendText(Environment.NewLine);
     }
 }
        public void GivenCachedAndStaledParentAndChildElements_WhenSubsequentCallsToChildElementAreMade_ShouldNotThrowStaleElementReferenceException()
        {
            WebElement soonToBeStaleParentElement = null;
            WebElement soonToBeStaleChildElement  = null;

            TestSteps
            .GoTo <ExamplesPage>((page, a) =>
            {
                soonToBeStaleParentElement = page.Form;
                soonToBeStaleChildElement  = page.FirstInputElement;

                Assert.Multiple(() =>
                {
                    MakeACallTo(soonToBeStaleChildElement);
                    Assert.That(soonToBeStaleParentElement.IsCached, Is.True, "Parent should be cached.");
                    Assert.That(soonToBeStaleChildElement.IsCached, Is.True, "Child element should be cached.");
                });
            })
            .GoTo <ExamplesPage>((page, a) =>
            {
                Assert.Multiple(() =>
                {
                    Assert.That(soonToBeStaleParentElement.IsStale, Is.True, "Parent should be staled now.");
                    Assert.That(soonToBeStaleChildElement.IsStale, Is.True, "Child element should be staled now.");

                    //Test starts here
                    Assert.That(() => MakeACallTo(soonToBeStaleChildElement),
                                Throws.Nothing,
                                $"Should not throw {typeof(StaleElementReferenceException)} neither on parent element, nor on child element.");
                    Assert.That(soonToBeStaleParentElement.IsStale, Is.False, "Parent should not be staled anymore as it was recached.");
                    Assert.That(soonToBeStaleChildElement.IsStale, Is.False, "Child element should not be staled anymore as it was recached.");
                    Assert.That(() => MakeACallTo(soonToBeStaleChildElement),
                                Throws.Nothing,
                                $"Should not throw {typeof(StaleElementReferenceException)} neither on parent element, nor on child element.");
                });
            });
        }
예제 #11
0
파일: SuiteProxy.cs 프로젝트: Pogosov/horus
        public override IMessage Invoke(IMessage msg)
        {
            if (msg == null)
            {
                throw new ArgumentNullException("msg", "The message containing invocation information cannot be null");
            }

            IMethodCallMessage methodCall      = msg as IMethodCallMessage;
            MethodInfo         decoratedMethod = methodCall.MethodBase as MethodInfo;

            var           reTryStepTime = 0;
            var           isReTryStep   = false;
            ReturnMessage returnMessage;

            do
            {
                var testStep = CreateTestStep(methodCall, decoratedMethod, TestCaseStatus, Index);
                Logger.LogMsg(Severity.INFO, $"Test step: {testStep.Name} started at: {DateTime.Now}... retry step time: {reTryStepTime}");

                object invokeResult = null;
                try
                {
                    if (testStep.Status == Status.Undefined)
                    {
                        bool isStoppedOnFail = Config.StopOnFail;
                        if (!isReTryStep && isStoppedOnFail && (PreviousStepStatus == Status.Failed || PreviousStepStatus == Status.Skipped))
                        {
                            testStep.SetStatus(Status.Skipped);
                        }
                        else
                        {
                            invokeResult = decoratedMethod.Invoke(this.Decorated, methodCall.Args);
                            testStep.SetValue(invokeResult);
                            testStep.SetStatus(Status.Passed);
                        }
                    }

                    returnMessage = new ReturnMessage(invokeResult, null, 0, methodCall.LogicalCallContext, methodCall);
                }
                catch (Exception ex)
                {
                    var screenName = $"{testStep.ID}_{decoratedMethod.Name}_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}.jpeg";
                    testStep.SetScreenshotPath($@"{Config.ReportToScreenshot}\{screenName}");
                    Logger.LogMsg(Severity.ERROR, $"Test step Screenshot file name: {screenName}.");

                    var screenPath = $@"{Config.ScreenshotPath}\{screenName}";
                    FwUtil.Screenshot.CaptureScreen(screenPath);

                    Logger.LogMsg(Severity.ERROR, $"Step exception: {ex.GetLastInnerException().Message}. StackTrace: {ex.GetLastInnerException().StackTrace}");
                    testStep.SetError($"Step exception: {ex.GetLastInnerException().Message}. StackTrace: {ex.GetLastInnerException().StackTrace}");

                    testStep.SetStatus(Status.Failed);
                    returnMessage = new ReturnMessage(invokeResult, null, 0, methodCall.LogicalCallContext, methodCall);
                    // Remark: do not return exception from a step method to test method so that we can continue next step !!!
                    // returnMessage = new ReturnMessage(ex, methodCall);
                }

                testStep.Finish();
                TestSteps.Add(testStep);

                PreviousStepStatus = testStep.Status;
                isReTryStep        = (reTryStepTime < Config.RetryStep && (PreviousStepStatus == Status.Failed));

                Logger.LogMsg(Severity.INFO, $"Test step: {testStep.Name} => Status is: {testStep.Status}...");
                Logger.LogMsg(Severity.INFO, $"Test step: {testStep.Name} completed at: {DateTime.Now}... retry step: {reTryStepTime}");

                reTryStepTime++;
                Index++;
            } while (isReTryStep);

            return(returnMessage);
        }
예제 #12
0
        public void AddStep(int stepNumber, string action, string expected)
        {
            TestStep currTestStep = new TestStep(stepNumber, action, expected);

            TestSteps.Add(currTestStep);
        }
예제 #13
0
 IEnumerator IEnumerable.GetEnumerator()
 {
     return(TestSteps.GetEnumerator());
 }
예제 #14
0
 public IEnumerator <TestStep> GetEnumerator()
 {
     return(TestSteps.GetEnumerator());
 }