Class HtmlContentValidator
- Namespace
- Xping.Sdk.Validations.Content.Html
- Assembly
- Xping.Sdk.dll
Represents a validator that checks if a html content matches a specified pattern or condition.
public class HtmlContentValidator : BaseContentValidator, ITestComponent
- Inheritance
-
HtmlContentValidator
- Implements
- Inherited Members
Remarks
note
The HtmlContentValidator component requires either the Browser BrowserRequestSender or HttpClient HttpClientRequestSender component to be registered before it in the pipeline, because it depends on the HTTP response results from these components.
Constructors
HtmlContentValidator(Action<IHtmlContent>)
Initializes a new instance of the HtmlContentValidator class.
public HtmlContentValidator(Action<IHtmlContent> validation)
Parameters
validation
Action<IHtmlContent>A function that determines whether the html content matches a specified condition.
Exceptions
- ArgumentNullException
Thrown when the validation function is null.
Fields
StepName
The name of the test component that represents a StringContentValidator test operation.
public const string StepName = "HtmlContentValidator"
Field Value
Remarks
This constant is used to register the StringContentValidator class in the test framework.
Methods
CreateHtmlContent(string, TestContext, string)
Creates an instance of IHtmlContent by combining the provided HTML data, test context, and a specified test ID attribute.
protected virtual IHtmlContent CreateHtmlContent(string content, TestContext context, string testIdAttribute)
Parameters
content
stringThe HTML data to include in the content.
context
TestContextThe test context.
testIdAttribute
stringThe attribute to use for identifying test-specific elements.
Returns
- IHtmlContent
An instance of IHtmlContent representing the instrumented HTML content.
HandleAsync(Uri, TestSettings, TestContext, IServiceProvider, CancellationToken)
This method performs the test step operation asynchronously.
public override Task HandleAsync(Uri url, TestSettings settings, TestContext context, IServiceProvider serviceProvider, CancellationToken cancellationToken = default)
Parameters
url
UriA Uri object that represents the URL of the page being validated.
settings
TestSettingsA TestSettings object that contains the settings for the test.
context
TestContextA TestContext object that represents the test context.
serviceProvider
IServiceProviderAn instance object of a mechanism for retrieving a service object.
cancellationToken
CancellationTokenAn optional CancellationToken object that can be used to cancel this operation.
Returns
Exceptions
- ArgumentNullException
If any of the following parameters: url, settings or context is null.