Interface IHtmlAssertions
- Namespace
- Xping.Sdk.Validations.Content.Html
- Assembly
- Xping.Sdk.dll
Represents an object for validating an HTML response.
public interface IHtmlAssertions
Methods
ToHaveExternalScript(string, TextOptions?)
Validates that an HTML document includes the specified external script.
IHtmlAssertions ToHaveExternalScript(string externalScript, TextOptions? options = null)
Parameters
externalScriptstringThe URL of the external script.
optionsTextOptionsOptional parameter for customizing the search text behavior.
Returns
- IHtmlAssertions
An instance of IHtmlAssertions to allow for further assertions.
ToHaveExternalStylesheet(string, TextOptions?)
Validates that an HTML document includes the specified external stylesheet.
IHtmlAssertions ToHaveExternalStylesheet(string externalStylesheet, TextOptions? options = null)
Parameters
externalStylesheetstringThe URL of the external stylesheet.
optionsTextOptionsOptional parameter for customizing the search text behavior.
Returns
- IHtmlAssertions
An instance of IHtmlAssertions to allow for further assertions.
ToHaveImageWithAltText(string, TextOptions?)
Validates that an HTML document contains an image with the specified alt text.
IHtmlAssertions ToHaveImageWithAltText(string altText, TextOptions? options = null)
Parameters
altTextstringThe alt attribute of the image.
optionsTextOptionsOptional parameter for customizing the search text behavior.
Returns
- IHtmlAssertions
An instance of IHtmlAssertions to allow for further assertions.
ToHaveImageWithAltText(Regex, TextOptions?)
Validates that an HTML document contains an image with the specified alt text.
IHtmlAssertions ToHaveImageWithAltText(Regex altText, TextOptions? options = null)
Parameters
altTextRegexThe regular expression used to match the alt text of the image.
optionsTextOptionsOptional parameter for customizing the search text behavior.
Returns
- IHtmlAssertions
An instance of IHtmlAssertions to allow for further assertions.
ToHaveImageWithSrc(string, TextOptions?)
Validates that an HTML document contains an image with the specified source URL.
IHtmlAssertions ToHaveImageWithSrc(string src, TextOptions? options = null)
Parameters
srcstringThe src attribute of the image.
optionsTextOptionsOptional parameter for customizing the search text behavior.
Returns
- IHtmlAssertions
An instance of IHtmlAssertions to allow for further assertions.
ToHaveImageWithSrc(Regex, TextOptions?)
Validates that an HTML document contains an image with the specified source URL.
IHtmlAssertions ToHaveImageWithSrc(Regex src, TextOptions? options = null)
Parameters
srcRegexThe regular expression used to match the src attribute of the image.
optionsTextOptionsOptional parameter for customizing the search text behavior.
Returns
- IHtmlAssertions
An instance of IHtmlAssertions to allow for further assertions.
ToHaveMaxDocumentSize(int)
Validates that the size in bytes of an HTML document is equal to or less than the specified maximum size.
IHtmlAssertions ToHaveMaxDocumentSize(int maxSizeInBytes)
Parameters
maxSizeInBytesintThe maximum allowed size of the HTML document in bytes.
Returns
- IHtmlAssertions
An instance of IHtmlAssertions to allow for further assertions.
ToHaveMetaTag(HtmlAttribute, int?)
Validates if the HTML meta tag with the specified attribute exist.
IHtmlAssertions ToHaveMetaTag(HtmlAttribute attribute, int? expectedCount = null)
Parameters
attributeHtmlAttributeThe HTML attribute to look for.
expectedCountint?The expected number of occurrences of the <meta> tag with the specified attribute. If not specified, the method will validate that at least one occurrence is present.
Returns
- IHtmlAssertions
An instance of IHtmlAssertions to allow for further assertions.
Examples
// For a given HTML
// <meta property="og:image" content="image.png">
Expect(html).ToHaveMetaTag(new("property", "og:image"));
ToHaveMetaTag(HtmlAttribute, string, TextOptions?)
Validates if the HTML meta tag with the specified attribute has the expected content value.
IHtmlAssertions ToHaveMetaTag(HtmlAttribute attribute, string expectedContent, TextOptions? options = null)
Parameters
attributeHtmlAttributeThe HTML attribute to look for.
expectedContentstringThe expected content of the meta tag.
optionsTextOptionsOptional parameter for customizing the search text behavior.
Returns
- IHtmlAssertions
A validation result indicating whether the meta tag has the expected content.
Examples
// For a given HTML
// <meta property="og:image" content="image.png">
Expect(html).ToHaveMetaTag(new HtmlAttribute("property", "og:image"), expectedContent: "image.png");
ToHaveTitle(string, TextOptions?)
Validates that an HTML document or element has the specified title. The title is typically found within the <title> tag in the <head> section of an HTML document.
IHtmlAssertions ToHaveTitle(string title, TextOptions? options = null)
Parameters
titlestringThe expected title to validate against.
optionsTextOptionsOptional parameter for customizing the search text behavior.
Returns
- IHtmlAssertions
An instance of IHtmlAssertions to allow for further assertions.
ToHaveTitle(Regex, TextOptions?)
Validates that an HTML document or element has the specified title. The title is typically found within the <title> tag in the <head> section of an HTML document.
IHtmlAssertions ToHaveTitle(Regex title, TextOptions? options = null)
Parameters
titleRegexThe regex expresion of the expected title to validate against.
optionsTextOptionsOptional parameter for customizing the search text behavior.
Returns
- IHtmlAssertions
An instance of IHtmlAssertions to allow for further assertions.