Table of Contents

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

externalScript string

The URL of the external script.

options TextOptions

Optional 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

externalStylesheet string

The URL of the external stylesheet.

options TextOptions

Optional 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

altText string

The alt attribute of the image.

options TextOptions

Optional 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

altText Regex

The regular expression used to match the alt text of the image.

options TextOptions

Optional 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

src string

The src attribute of the image.

options TextOptions

Optional 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

src Regex

The regular expression used to match the src attribute of the image.

options TextOptions

Optional 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

maxSizeInBytes int

The 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

attribute HtmlAttribute

The HTML attribute to look for.

expectedCount int?

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

attribute HtmlAttribute

The HTML attribute to look for.

expectedContent string

The expected content of the meta tag.

options TextOptions

Optional 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

title string

The expected title to validate against.

options TextOptions

Optional 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

title Regex

The regex expresion of the expected title to validate against.

options TextOptions

Optional parameter for customizing the search text behavior.

Returns

IHtmlAssertions

An instance of IHtmlAssertions to allow for further assertions.