Table of Contents

Class ElementSnapshot

Namespace
Ranorex.Core
Assembly
Ranorex.Core.dll

Represents the container for a tree of element snapshots.

public class ElementSnapshot
Inheritance
ElementSnapshot
Inherited Members

Properties

Config

Gets the configuration that was used to create the snapshot with.

public Configuration Config { get; }

Property Value

Configuration

Description

An optional description of the snapshot.

public string Description { get; set; }

Property Value

string

Element

The snapshotted element that the snapshot was created for, i.e. the returned snapshotted element corresponds to the element passed to the Capture method.

public Element Element { get; }

Property Value

Element

RootElement

The root element of the snapshotted element tree.

public Element RootElement { get; }

Property Value

Element

ScreenShot

A screenshot of the previously captured element.

public CompressedImage ScreenShot { get; }

Property Value

CompressedImage

TimeStamp

The timestamp when the snapshot was made.

public DateTime TimeStamp { get; }

Property Value

DateTime

Methods

Capture(Element, bool)

Creates a new snapshot from a given (live) element instance.

public static ElementSnapshot Capture(Element element, bool includeImage)

Parameters

element Element

The element to be snapshotted.

includeImage bool

Defines if a screenshot of the element should be included in the snapshot.

Returns

ElementSnapshot

A snapshot of the element tree.

Remarks

Depending on the configuration setting CompleteAncestorSnapshot, the snapshot will include the complete subtree of all ancestor elements.

Capture(Element, bool, bool)

Creates a new snapshot from a given (live) element instance.

public static ElementSnapshot Capture(Element element, bool includeImage, bool topLevelSnapshot)

Parameters

element Element

The element to be snapshotted.

includeImage bool

Defines if a screenshot of the element should be included in the snapshot.

topLevelSnapshot bool

Specifies whether to include the complete subtree for all ancestor elements of the element.

Returns

ElementSnapshot

A snapshot of the element tree.

CreateFromFile(string)

Load a snapshot from a file and create an instance for it.

public static ElementSnapshot CreateFromFile(string fileName)

Parameters

fileName string

The file (optionally including a path) to load the snapshot from.

Returns

ElementSnapshot

The newly created instance loaded from the specified file.

Remarks

The snapshot contained in the specified file can both be compressed or non-compressed.

Exceptions

RanorexException

If loading the snapshot fails.

CreateSimpleClone(Element, int)

Creates a simple clone snapshot of the element.

public static Element CreateSimpleClone(Element element, int depth)

Parameters

element Element

The element to use for the snapshot.

depth int

The tree depth for the snapshot. (0=element itself).

Returns

Element

The cloned element.

CreateSimpleClone(Element, int, bool)

Creates a simple clone snapshot of the element.

public static Element CreateSimpleClone(Element element, int depth, bool includeDynamicAttributes)

Parameters

element Element

The element to use for the snapshot.

depth int

The tree depth for the snapshot. (0=element itself).

includeDynamicAttributes bool

Determines whether dynamic attributes are captured.

Returns

Element

The cloned element.

DeserializeXml(XmlDoc)

Creates a snapshot from an XML document.

public static ElementSnapshot DeserializeXml(XmlDoc xmlDoc)

Parameters

xmlDoc XmlDoc

The XML document from which to restore the snapshot.

Returns

ElementSnapshot

The restored snapshot.

DeserializeXml(string)

Creates a snapshot from an XML document string.

public static ElementSnapshot DeserializeXml(string xml)

Parameters

xml string

The XML string from which to restore the snapshot.

Returns

ElementSnapshot

The restored snapshot.

SaveToFile(string, bool)

Saves the snapshot to a file.

public void SaveToFile(string fileName, bool compress = true)

Parameters

fileName string

The file (optionally including a path) to save the snapshot to.

compress bool

Specifies whether to compress the snapshot (default: true).

Remarks

It is recommended to use the file extension "rxsnp" for the fileName to allow for maximal interoperability with Ranorex tools.

Exceptions

RanorexException

If saving the snapshot fails.

SerializeXml()

Serializes the complete snapshot as an XML document string.

public string SerializeXml()

Returns

string

The snapshot XML string.

SerializeXmlDoc()

Serializes the complete snapshot as an XML document.

public XmlDoc SerializeXmlDoc()

Returns

XmlDoc

The snapshot XML document.