public override List <ResponseAssertionResults> Execute(HttpRequestDto httpRequestDto, IMeasuredResponse response) { ResponseAssertionResultsCollection.Clear(); if (httpRequestDto.ResponseAssertions.Count > 0) { foreach (var responseAssertion in httpRequestDto.ResponseAssertions) { var responseAssertionResults = new ResponseAssertionResults { AssertionType = responseAssertion.ToString() }; var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(response.Content); if (_loadTestLocators.Any(x => x.LocatorType.Equals(responseAssertion.Locator))) { var currentLocator = _loadTestLocators.First(x => x.LocatorType.Equals(responseAssertion.Locator)); try { LoadTestElement htmlElement = currentLocator.LocateElement(htmlDocument, responseAssertion.LocatorValue); if (_loadTestEnsureHandler.Any(x => x.EnsureType.Equals(responseAssertion.AssertionType))) { var currentEnsureHandler = _loadTestEnsureHandler.First(x => x.EnsureType.Equals(responseAssertion.AssertionType)); responseAssertionResults = currentEnsureHandler.Execute(htmlElement, responseAssertion.ExpectedValue); } else { responseAssertionResults.FailedMessage = $"AssertionType {responseAssertion.AssertionType} is not supported."; responseAssertionResults.Passed = false; } } catch (Exception ex) { responseAssertionResults.FailedMessage = ex.Message; responseAssertionResults.Passed = false; } } else { responseAssertionResults.FailedMessage = $"Locator {responseAssertion.Locator} is not supported."; responseAssertionResults.Passed = false; } ResponseAssertionResultsCollection.Add(responseAssertionResults); } } return(ResponseAssertionResultsCollection); }
public override ResponseAssertionResults Execute(LoadTestElement loadTestElement, string expectedValue) { var responseAssertionResults = new ResponseAssertionResults(); if (loadTestElement.HtmlNode.GetAttributeValue("accesskey", string.Empty) != expectedValue) { responseAssertionResults.AssertionType = $"{ValidateType}- {loadTestElement.Locator}={loadTestElement.LocatorValue} Expected = {expectedValue}"; responseAssertionResults.Passed = false; responseAssertionResults.FailedMessage = $"Element with locator {loadTestElement.Locator}={loadTestElement.LocatorValue} accesskey wasn't equal to {expectedValue}."; } return responseAssertionResults; }
public override ResponseAssertionResults Execute(LoadTestElement loadTestElement, string expectedValue) { var responseAssertionResults = new ResponseAssertionResults(); if (loadTestElement.HtmlNode.GetAttributeValue("longdesc", string.Empty) != string.Empty) { responseAssertionResults.AssertionType = $"{ValidateType}- {loadTestElement.Locator}={loadTestElement.LocatorValue} Expected = {expectedValue}"; responseAssertionResults.Passed = false; responseAssertionResults.FailedMessage = $"Element with locator {loadTestElement.Locator}={loadTestElement.LocatorValue} longdesc wasn't null."; } return(responseAssertionResults); }
public override ResponseAssertionResults Execute(LoadTestElement loadTestElement, string expectedValue) { var responseAssertionResults = new ResponseAssertionResults(); if (!loadTestElement.HtmlNode.InnerText.Contains(expectedValue)) { responseAssertionResults.AssertionType = $"{ValidateType}- {loadTestElement.Locator}={loadTestElement.LocatorValue} Expected = {expectedValue}"; responseAssertionResults.Passed = false; responseAssertionResults.FailedMessage = $"Element with locator {loadTestElement.Locator}={loadTestElement.LocatorValue} InnerText didn't contain {expectedValue}"; } return(responseAssertionResults); }
public override ResponseAssertionResults Execute(LoadTestElement loadTestElement, string expectedValue) { var responseAssertionResults = new ResponseAssertionResults(); if (loadTestElement.HtmlNode == null) { responseAssertionResults.AssertionType = $"{ValidateType}- {loadTestElement.Locator}={loadTestElement.LocatorValue} Expected = {expectedValue}"; responseAssertionResults.Passed = false; responseAssertionResults.FailedMessage = $"Element with locator {loadTestElement.Locator}={loadTestElement.LocatorValue} was visible."; } return(responseAssertionResults); }
public override ResponseAssertionResults Execute(LoadTestElement loadTestElement, string expectedValue) { var responseAssertionResults = new ResponseAssertionResults(); if (loadTestElement.HtmlNode.InnerText != expectedValue) { responseAssertionResults.AssertionType = $"{EnsureType}- {loadTestElement.Locator}={loadTestElement.LocatorValue} Expected = {expectedValue}"; responseAssertionResults.Passed = false; responseAssertionResults.FailedMessage = $"Element with locator {loadTestElement.Locator}={loadTestElement.LocatorValue} text wasn't equal to {expectedValue} it was {loadTestElement.HtmlNode.InnerText}."; } return(responseAssertionResults); }
public override List <ResponseAssertionResults> Execute(HttpRequestDto httpRequestDto, IMeasuredResponse response) { ResponseAssertionResultsCollection.Clear(); var responseAssertionResults = new ResponseAssertionResults { AssertionType = "StatusCode is SUCCESS", Passed = true, }; if ((int)response.StatusCode <= 200 && (int)response.StatusCode >= 299) { responseAssertionResults.FailedMessage = $"Request's status code was not successful - {response.StatusCode} {response.ResponseUri}."; } ResponseAssertionResultsCollection.Add(responseAssertionResults); return(ResponseAssertionResultsCollection); }