public string RegisterElement(WiniumElement element) { var registeredKey = this.registredElements.FirstOrDefault(x => x.Value.Equals(element)).Key; if (registeredKey == null) { registeredKey = GenerateGuid(element); this.registredElements.Add(registeredKey, element); } return registeredKey; }
private void WriteElementToXml(XmlWriter writer, WiniumElement element) { if (element == null) { return; } writer.WriteStartElement(element.ClassName); var rect = element.GetRect(); var attributes = new Dictionary<string, string> { { "name", element.AutomationName }, { "id", element.AutomationId }, { "xname", element.XName }, { "visible", element.IsUserVisible().ToString().ToLowerInvariant() }, { "value", element.GetText() }, { "x", rect.X.ToString(CultureInfo.InvariantCulture) }, { "y", rect.Y.ToString(CultureInfo.InvariantCulture) }, { "width", rect.Width.ToString(CultureInfo.InvariantCulture) }, { "height", rect.Height.ToString(CultureInfo.InvariantCulture) }, { "clickable_point", element.GetCoordinatesInView() .ToString(CultureInfo.InvariantCulture) } }; foreach (var attribute in attributes) { writer.WriteAttributeString(attribute.Key, attribute.Value); } foreach (var child in element.Find(TreeScope.Children, x => true)) { this.WriteElementToXml(writer, child); } writer.WriteEndElement(); }
private static string GenerateGuid(WiniumElement element) { Interlocked.Increment(ref safeInstanceCount); return element.GetHashCode() + "-" + safeInstanceCount.ToString(string.Empty, CultureInfo.InvariantCulture); }