/// <summary> /// Gets the original Uia element. /// </summary> /// <param name="element">The element.</param> /// <returns>The Uia element.</returns> public static IUITechnologyElement GetUiaElement(IUITechnologyElement element) { CommonControlElement te = element as CommonControlElement; if (te != null) { return(te.InnerElement); } return(null); }
/// <summary> /// Determines whether the specified object is equal to the current object. /// </summary> /// <param name="element">The object to compare with the current object.</param> /// <returns>True if the specified object is equal to the current object; otherwise, false.</returns> public override bool Equals(IUITechnologyElement element) { var otherElement = element as GridControlElement; if (otherElement != null) { return(string.Equals(this.Name, otherElement.Name, StringComparison.Ordinal)); } return(false); }
/// <summary> /// Gets the parent of the given element in the user interface hierarchy. /// </summary> /// <param name="element">The element whose parent is needed.</param> /// <returns>The parent element or null if the element passed is the /// root element in this technology.</returns> public override IUITechnologyElement GetParent(IUITechnologyElement element) { WordRange wordRange = element as WordRange; if (wordRange != null) { return(wordRange.Parent); } return(null); }
/// <summary> /// Determines whether the specified object is equal to the current object. /// </summary> /// <param name="element">The object to compare with the current object.</param> /// <returns>True if the specified object is equal to the current object; otherwise, false.</returns> public override bool Equals(IUITechnologyElement element) { CommonControlElement other = element as CommonControlElement; if ((object)other != null) { return(InnerElement.Equals(other.InnerElement)); } return(false); }
/// <summary> /// Determines whether the specified object is equal to the current object. /// </summary> /// <param name="element">The object to compare with the current object.</param> /// <returns>True if the specified object is equal to the current object; otherwise, false.</returns> public override bool Equals(IUITechnologyElement element) { WordRange otherRange = element as WordRange; if (otherRange != null) { // Compare Name as window handle is sometime of hidden Word window. return(string.Equals(this.Name, otherRange.Name, StringComparison.Ordinal)); } return(false); }
/// <summary> /// Gets the parent of the given element in the user interface hierarchy. /// </summary> /// <param name="element">The element whose parent is needed.</param> /// <returns>The parent element or null if the element passed is the /// root element in this technology.</returns> public override IUITechnologyElement GetParent(IUITechnologyElement element) { coreelement = element; var cellElement = element as GridCellElement; if (cellElement != null) { return(cellElement.Parent); } return(null); }
public override bool Equals(IUITechnologyElement element) { if (base.Equals(element)) { GridCellElement otherElement = element as GridCellElement; if (otherElement != null) { return(this.CellInfo.Equals(otherElement.CellInfo)); } } return(false); }
/// <summary> /// Determines whether the specified object is equal to the current object. /// </summary> /// <param name="element">The object to compare with the current object.</param> /// <returns>True if the specified object is equal to the current object; otherwise, false.</returns> public override bool Equals(IUITechnologyElement element) { if (base.Equals(element)) { WordSelectionRange otherElement = element as WordSelectionRange; if (otherElement != null) { return(this.SelectionInfo.Equals(otherElement.SelectionInfo)); } } return(false); }
/// <summary> /// Determines whether the specified object is equal to the current object. /// </summary> /// <param name="element">The object to compare with the current object.</param> /// <returns>True if the specified object is equal to the current object; otherwise, false.</returns> public override bool Equals(IUITechnologyElement element) { if (base.Equals(element)) { WordDocumentRange otherRange = element as WordDocumentRange; if (otherRange != null) { return(object.Equals(this.DocumentInfo, otherRange.DocumentInfo)); } } return(false); }
/// <summary> /// Gets the enumerator for children of the given IUITechnologyElement. /// </summary> /// <param name="element">The IUITechnologyElement whose child enumerator is needed.</param> /// <param name="parsedQueryIdCookie">The cookie of previously parsed QueryId to filter matching children.</param> /// <returns>The enumerator for children.</returns> /// <seealso cref="ParseQueryId"/> public override System.Collections.IEnumerator GetChildren(IUITechnologyElement element, object parsedQueryIdCookie) { if (parsedQueryIdCookie != null) { // this conversion is while playback the test casees for grid cell we need to get childrens of DataGrid . //so we create instance of GridControlElement instead of CommonControlElement var conditionsStack = ((parsedQueryIdCookie as QueryCondition).Conditions as IQueryCondition[]); foreach (var item in conditionsStack) { if (!(item is PropertyCondition)) { continue; } var controlType = (item as PropertyCondition).Value; var property = (item as PropertyCondition).PropertyName; if (property == "ControlType" && controlType.ToString() == "Cell" && !(element is GridControlElement)) { element = new GridControlElement(element.WindowHandle, this); break; } } } var gridElement = element as GridControlElement; var condition = parsedQueryIdCookie as AndCondition; coreelement = element; if (gridElement != null) { if (condition != null) { return(gridElement.GetChildren(condition)); } else { // TODO - return all children } } else { return(new ChildrenEnumerator(this, (Playback.GetCoreTechnologyManager("UIA")).GetChildren(Utilities.GetUiaElement(element), parsedQueryIdCookie))); } return(null); }
/// <summary> /// Gets the enumerator for children of the given IUITechnologyElement. /// </summary> /// <param name="element">The IUITechnologyElement whose child enumerator is needed.</param> /// <param name="parsedQueryIdCookie">The cookie of previously parsed QueryId to filter matching children.</param> /// <returns>The enumerator for children.</returns> /// <seealso cref="ParseQueryId"/> public override System.Collections.IEnumerator GetChildren(IUITechnologyElement element, object parsedQueryIdCookie) { WordRange wordRange = element as WordRange; AndCondition condition = parsedQueryIdCookie as AndCondition; if (wordRange != null) { if (condition != null) { return(wordRange.GetChildren(condition)); } return(new UITechnologyElement[] { }.GetEnumerator()); } return(null); }
/// <summary> /// Matches the element against the parsedQueryIdCookie condition. /// </summary> /// <param name="element">The element to match against the conditions.</param> /// <param name="parsedQueryIdCookie">The cookie of previously parsed QueryId.</param> /// <param name="useEngine"> /// This is set to true by the technology manager if it wants to use /// the framework for matching the complete or part of query element.</param> /// <returns>True if the element matches the condition, false otherwise.</returns> /// <remarks> /// This is an optional method and if the technology manager does not support /// this method it should throw System.NotSupportedException exception. If the Search() /// is not supported then the framework uses GetChildren() API to do breadth-first /// traversal and for each element uses MatchElement() API to match & find. /// /// Note that a technology has to support either this or Search. /// </remarks> /// <seealso cref="ParseQueryId"/> /// <seealso cref="Search"/> public override bool MatchElement(IUITechnologyElement element, object parsedQueryIdCookie, out bool useEngine) { // Get the condition out of the cookie as set by ParseQueryId() API. IQueryCondition condition = parsedQueryIdCookie as AndCondition; if (condition != null) { // Use the Match API to do the matching. Note that this API // will call into ExcelElement.GetPropertyValue() method to // get the value of the properties for matching. useEngine = false; return(condition.Match(element)); } else { useEngine = true; return(false); } }
/// <summary> /// Converts the given element of another technology to new element of this technology manager. /// This is used for operations like switching between hosted and hosting technologies. /// </summary> /// <param name="elementToConvert">The element to convert.</param> /// <param name="supportLevel">The level of support provided for the /// converted element by this technology manager.</param> /// <returns>The new converted element in this technology or null if no conversion is possible.</returns> /// <seealso cref="GetControlSupportLevel"/> /// <seealso cref="ControlSupport"/> public override IUITechnologyElement ConvertToThisTechnology(IUITechnologyElement elementToConvert, out int supportLevel) { supportLevel = (int)ControlSupport.NoSupport; coreelement = elementToConvert; if (elementToConvert is GridControlElement) { supportLevel = (int)ControlSupport.ControlSpecificSupport; return(elementToConvert); } else { var windowHandle = elementToConvert.WindowHandle; if (Utilities.IsGridControlWindow(windowHandle)) { supportLevel = (int)ControlSupport.ControlSpecificSupport; return(GetGridElement(windowHandle, null)); } } return(null); }
public override IUITechnologyElement ConvertToExtensionElement(IUITechnologyElement coreElement) { coreelement = coreElement; #if SyncfusionFramework4_5_1 || SyncfusionFramework4_6 //From Visual studio update 2 they provided support for window less control (Windows Store app) // Due to this we must implement this override method.this method is executed instead of GetEleemntFromPoint() method. var element = GridCommunicator.Instance.GetElementFromPoint(Mouse.Location.X, Mouse.Location.Y); if (element == null) { var element1 = (Playback.GetCoreTechnologyManager("UIA")).GetElementFromPoint(Mouse.Location.X, Mouse.Location.Y); if (Utilities.IsUiaElement(element1)) { return(new CommonControlElement(coreelement.WindowHandle, this, element1)); } return(null); } return(this.GetGridElement(coreelement.WindowHandle, element)); #else throw new NotImplementedException(); #endif }
/// <summary> /// Converts the given element of another technology to new element of this technology manager. /// This is used for operations like switching between hosted and hosting technologies. /// </summary> /// <param name="elementToConvert">The element to convert.</param> /// <param name="supportLevel">The level of support provided for the /// converted element by this technology manager.</param> /// <returns>The new converted element in this technology or null if no conversion is possible.</returns> /// <seealso cref="GetControlSupportLevel"/> /// <seealso cref="ControlSupport"/> public override IUITechnologyElement ConvertToThisTechnology(IUITechnologyElement elementToConvert, out int supportLevel) { supportLevel = (int)ControlSupport.NoSupport; if (elementToConvert is ExcelElement) { // If already an Excel UI element, no need to convert. supportLevel = (int)ControlSupport.ControlSpecificSupport; return elementToConvert; } else { // If this is an Excel worksheet window, convert appropriate. IntPtr windowHandle = elementToConvert.WindowHandle; if (Utilities.IsExcelWorksheetWindow(windowHandle)) { supportLevel = (int)ControlSupport.ControlSpecificSupport; return GetExcelElement(windowHandle, null); } } // Return null for other cases. return null; }
/// <summary> /// Searches for an element matching the given query element. If the underlying /// UI Technology has rich APIs to search/navigate the UI hierarchy then /// implementing this method could improve the playback performance significantly. /// </summary> /// <param name="parsedQueryIdCookie">The cookie of previously parsed QueryId.</param> /// <param name="parentElement">The parent element under which to search.</param> /// <param name="maxDepth">The maximum tree depth to search.</param> /// <returns>An array of matched elements or null if none matched.</returns> /// <remarks> /// This is an optional method and if the technology manager does not support /// this method it should throw System.NotSupportedException exception. If this /// is not supported then the framework uses GetChildren() API to do breadth-first /// traversal and for each element uses MatchElement() API to match and find. /// Note that a technology has to support either this or MatchElement. /// </remarks> /// <seealso cref="ParseQueryId"/> /// <seealso cref="MatchElement"/> /// <seealso cref="UITechnologyManagerProperty.SearchSupported"/> public override object[] Search(object parsedQueryIdCookie, IUITechnologyElement parentElement, int maxDepth) { throw new NotSupportedException(); }
/// <summary> /// Gets the previous sibling of the given element in the user interface hierarchy. /// </summary> /// <param name="element">The element whose previous sibling is needed.</param> /// <returns>The previous sibling or null if none is present.</returns> public override IUITechnologyElement GetPreviousSibling(IUITechnologyElement element) { // TODO - Sibling navigation is required to get the arrow keys of Spy control working. return(null); }
/// <summary> /// Searches for an element matching the given query element. If the underlying /// UI Technology has rich APIs to search/navigate the UI hierarchy then /// implementing this method could improve the playback performance significantly. /// </summary> /// <param name="parsedQueryIdCookie">The cookie of previously parsed QueryId.</param> /// <param name="parentElement">The parent element under which to search.</param> /// <param name="maxDepth">The maximum tree depth to search.</param> /// <returns>An array of matched elements or null if none matched.</returns> /// <remarks> /// This is an optional method and if the technology manager does not support /// this method it should throw System.NotSupportedException exception. If this /// is not supported then the framework uses GetChildren() API to do breadth-first /// traversal and for each element uses MatchElement() API to match & find. /// /// Note that a technology has to support either this or MatchElement. /// </remarks> /// <seealso cref="ParseQueryId"/> /// <seealso cref="MatchElement"/> /// <seealso cref="UITechnologyManagerProperty.SearchSupported"/> public override object[] Search(object parsedQueryIdCookie, IUITechnologyElement parentElement, int maxDepth) { throw new NotSupportedException(); }
/// <summary> /// Matches the element against the parsedQueryIdCookie condition. /// </summary> /// <param name="element">The element to match against the conditions.</param> /// <param name="parsedQueryIdCookie">The cookie of previously parsed QueryId.</param> /// <param name="useEngine"> /// This is set to true by the technology manager if it wants to use /// the framework for matching the complete or part of query element.</param> /// <returns>True if the element matches the condition, false otherwise.</returns> /// <remarks> /// This is an optional method and if the technology manager does not support /// this method it should throw System.NotSupportedException exception. If the Search() /// is not supported then the framework uses GetChildren() API to do breadth-first /// traversal and for each element uses MatchElement() API to match & find. /// /// Note that a technology has to support either this or Search. /// </remarks> /// <seealso cref="ParseQueryId"/> /// <seealso cref="Search"/> public override bool MatchElement(IUITechnologyElement element, object parsedQueryIdCookie, out bool useEngine) { // Get the condition out of the cookie as set by ParseQueryId() API. IQueryCondition condition = parsedQueryIdCookie as AndCondition; if (condition != null) { // Use the Match API to do the matching. Note that this API // will call into ExcelElement.GetPropertyValue() method to // get the value of the properties for matching. useEngine = false; return condition.Match(element); } else { useEngine = true; return false; } }
/// <summary> /// Creates a element from the UIA element. /// </summary> /// <param name="technologyManager">The technology manager.</param> /// <param name="innerElement">The UIA element.</param> internal CommonControlElement(IntPtr windowHandle, UITechnologyManager technologyManager, IUITechnologyElement innerElement) { //if (!Utilities.IsUiaElement(innerElement)) //{ // throw new ArgumentException(); //} this.windowHandle = windowHandle; this.innerElement = innerElement as UITechnologyElement; this.technologyManager = technologyManager; }
/// <summary> /// Determines whether the specified object is equal to the current object. /// </summary> /// <param name="element">The object to compare with the current object.</param> /// <returns>True if the specified object is equal to the current object; otherwise, false.</returns> public override bool Equals(IUITechnologyElement element) { if (base.Equals(element)) { ExcelCellElement otherElement = element as ExcelCellElement; if (otherElement != null) { return this.CellInfo.Equals(otherElement.CellInfo); } } return false; }
/// <summary> /// Adds an event handler. /// </summary> /// <param name="element">The element and its descendants for which this event should be fired.</param> /// <param name="eventType">The type of event to listen to.</param> /// <param name="eventSink">The event sink which should be notified /// when the event occurs.</param> /// <returns>True if the eventType is supported and add is successful, false otherwise.</returns> public override bool AddEventHandler(IUITechnologyElement element, UITestEventType eventType, IUITestEventNotify eventSink) { return false; }
/// <summary> /// Removes an event handler. /// </summary> /// <param name="element">The element and its descendants for which this event should be removed.</param> /// <param name="eventType">The type of event to listen to.</param> /// <param name="eventSink">The event sink interface that was registered.</param> /// <returns>True if the eventType is supported and remove is successful, false otherwise.</returns> public override bool RemoveEventHandler(IUITechnologyElement element, UITestEventType eventType, IUITestEventNotify eventSink) { return(false); }
/// <summary> /// Gets a synchronization waiter for given UITestEventType on this element. /// </summary> /// <param name="element">The element to get synchronization waiter for.</param> /// <param name="eventType">The event for which synchronization waiter is required.</param> /// <returns> /// The synchronization waiter for specified event or null if event/waiter is not supported. /// </returns> public override IUISynchronizationWaiter GetSynchronizationWaiter(IUITechnologyElement element, UITestEventType eventType) { return(null); }
/// <summary> /// Gets the previous sibling of the given element in the user interface hierarchy. /// </summary> /// <param name="element">The element whose previous sibling is needed.</param> /// <returns>The previous sibling or null if none is present.</returns> public override IUITechnologyElement GetPreviousSibling(IUITechnologyElement element) { // TODO - Sibling navigation is required to get the arrow keys of Spy control working. return null; }
/// <summary> /// Determines whether the specified object is equal to the current object. /// </summary> /// <param name="element">The object to compare with the current object.</param> /// <returns>True if the specified object is equal to the current object; otherwise, false.</returns> public override bool Equals(IUITechnologyElement element) { if (base.Equals(element)) { ExcelWorksheetElement otherElement = element as ExcelWorksheetElement; if (otherElement != null) { return object.Equals(this.WorksheetInfo, otherElement.WorksheetInfo); } } return false; }
/// <summary> /// Determines whether the specified object is equal to the current object. /// </summary> /// <param name="element">The object to compare with the current object.</param> /// <returns>True if the specified object is equal to the current object; otherwise, false.</returns> public override bool Equals(IUITechnologyElement element) { ExcelElement otherElement = element as ExcelElement; if (otherElement != null) { // Compare Name as window handle is sometime of hidden EXCEL6 window. return string.Equals(this.Name, otherElement.Name, StringComparison.Ordinal); } return false; }
/// <summary> /// Gets the parent of the given element in the user interface hierarchy. /// </summary> /// <param name="element">The element whose parent is needed.</param> /// <returns>The parent element or null if the element passed is the /// root element in this technology.</returns> public override IUITechnologyElement GetParent(IUITechnologyElement element) { ExcelElement excelElement = element as ExcelElement; if (excelElement != null) { return excelElement.Parent; } return null; }
/// <summary> /// Converts the given element of another technology to new element of this technology manager. /// This is used for operations like switching between hosted and hosting technologies. /// </summary> /// <param name="elementToConvert">The element to convert.</param> /// <param name="supportLevel">The level of support provided for the /// converted element by this technology manager.</param> /// <returns>The new converted element in this technology or null if no conversion is possible.</returns> /// <seealso cref="GetControlSupportLevel"/> /// <seealso cref="ControlSupport"/> public override IUITechnologyElement ConvertToThisTechnology(IUITechnologyElement elementToConvert, out int supportLevel) { supportLevel = (int)ControlSupport.NoSupport; return(null); }
/// <summary> /// Gets the amount scrolled in percentage. /// </summary> /// <param name="srollDirection">The direction for which data is required.</param> /// <param name="scrollElement">The element which is either the vertical or horizontal scroll bar.</param> /// <returns>The amount in percentage.</returns> /// <seealso cref="InitializeProgrammaticScroll"/> public override int GetScrolledPercentage(ScrollDirection scrollDirection, IUITechnologyElement scrollElement) { return(InnerElement.GetScrolledPercentage(scrollDirection, scrollElement)); }
/// <summary> /// Gets the enumerator for children of the given IUITechnologyElement. /// </summary> /// <param name="element">The IUITechnologyElement whose child enumerator is needed.</param> /// <param name="parsedQueryIdCookie">The cookie of previously parsed QueryId to filter matching children.</param> /// <returns>The enumerator for children.</returns> /// <seealso cref="ParseQueryId"/> public override System.Collections.IEnumerator GetChildren(IUITechnologyElement element, object parsedQueryIdCookie) { ExcelElement excelElement = element as ExcelElement; AndCondition condition = parsedQueryIdCookie as AndCondition; if (excelElement != null) { if (condition != null) { return excelElement.GetChildren(condition); } else { return new UITechnologyElement[] { }.GetEnumerator(); } } return null; }
/// <summary> /// Gets the amount scrolled in percentage. /// </summary> /// <param name="scrollDirection">The direction for which data is required.</param> /// <param name="scrollElement">The element which is either the vertical or horizontal scroll bar.</param> /// <returns>The amount in percentage.</returns> /// <seealso cref="InitializeProgrammaticScroll"/> public override int GetScrolledPercentage(ScrollDirection scrollDirection, IUITechnologyElement scrollElement) { // Should never get called because InitializeProgrammaticScroll() returns false. throw new NotSupportedException(); }
/// <summary> /// Gets a synchronization waiter for given UITestEventType on this element. /// </summary> /// <param name="element">The element to get synchronization waiter for.</param> /// <param name="eventType">The event for which synchronization waiter is required.</param> /// <returns> /// The synchronization waiter for specified event or null if event/waiter is not supported. /// </returns> public override IUISynchronizationWaiter GetSynchronizationWaiter(IUITechnologyElement element, UITestEventType eventType) { return null; }
/// <summary> /// Gets the amount scrolled in percentage. /// </summary> /// <param name="srollDirection">The direction for which data is required.</param> /// <param name="scrollElement">The element which is either the vertical or horizontal scroll bar.</param> /// <returns>The amount in percentage.</returns> /// <seealso cref="InitializeProgrammaticScroll"/> public override int GetScrolledPercentage(ScrollDirection scrollDirection, IUITechnologyElement scrollElement) { // Should never get called because InitializeProgrammaticScroll() returns false. throw new NotSupportedException(); }
/// <summary> /// Checks if this element is from Uia technology manager. /// </summary> /// <param name="element">The element.</param> /// <returns>True if this is Uia technology element, false otherwise.</returns> public static bool IsUiaElement(IUITechnologyElement element) { return(element != null && string.Equals(element.TechnologyName, "UIA", StringComparison.OrdinalIgnoreCase)); }