Class ElementSnapshot
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
Description
An optional description of the snapshot.
public string Description { get; set; }
Property Value
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
RootElement
The root element of the snapshotted element tree.
public Element RootElement { get; }
Property Value
ScreenShot
A screenshot of the previously captured element.
public CompressedImage ScreenShot { get; }
Property Value
TimeStamp
The timestamp when the snapshot was made.
public DateTime TimeStamp { get; }
Property Value
Methods
Capture(Element, bool)
Creates a new snapshot from a given (live) element instance.
public static ElementSnapshot Capture(Element element, bool includeImage)
Parameters
elementElementThe element to be snapshotted.
includeImageboolDefines 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
elementElementThe element to be snapshotted.
includeImageboolDefines if a screenshot of the element should be included in the snapshot.
topLevelSnapshotboolSpecifies 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
fileNamestringThe 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
elementElementThe element to use for the snapshot.
depthintThe 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
elementElementThe element to use for the snapshot.
depthintThe tree depth for the snapshot. (0=element itself).
includeDynamicAttributesboolDetermines 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
xmlDocXmlDocThe 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
xmlstringThe 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
fileNamestringThe file (optionally including a path) to save the snapshot to.
compressboolSpecifies 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.