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."); }); }); }
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); }
private void ResetTest() { TestComment = string.Empty; TestSteps.Clear(); foreach (var ts in Map(_execution.Steps)) { TestSteps.Add(ts); } }
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"; }
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); } } }
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); } } }
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"); }); }); }
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."); }); }); }
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."); }); }); }
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); }
public void AddStep(int stepNumber, string action, string expected) { TestStep currTestStep = new TestStep(stepNumber, action, expected); TestSteps.Add(currTestStep); }
IEnumerator IEnumerable.GetEnumerator() { return(TestSteps.GetEnumerator()); }
public IEnumerator <TestStep> GetEnumerator() { return(TestSteps.GetEnumerator()); }