Class ComponentLocator
- java.lang.Object
-
- com.vaadin.client.componentlocator.ComponentLocator
-
public class ComponentLocator extends Object
ComponentLocator provides methods for generating a String locator for a given DOM element and for locating a DOM element using a String locator.The main use for this class is locating components for automated testing purposes.
- Since:
- 7.2, moved from
com.vaadin.client.ComponentLocator
-
-
Constructor Summary
Constructors Constructor Description ComponentLocator(ApplicationConnection client)Construct a ComponentLocator for the given ApplicationConnection.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ApplicationConnectiongetClient()Returns theApplicationConnectionused by this locator.com.google.gwt.user.client.ElementgetElementByPath(String path)Locates an element using a String locator (path) which identifies a DOM element.com.google.gwt.user.client.ElementgetElementByPathStartingAt(String path, com.google.gwt.dom.client.Element root)Locates an element using a String locator (path) which identifies a DOM element.com.google.gwt.core.client.JsArray<com.google.gwt.dom.client.Element>getElementsByPath(String path)Locates elements using a String locator (path) which identifies DOM elements.com.google.gwt.core.client.JsArray<com.google.gwt.dom.client.Element>getElementsByPathStartingAt(String path, com.google.gwt.dom.client.Element root)Locates elements using a String locator (path) which identifies DOM elements.StringgetPathForElement(com.google.gwt.dom.client.Element targetElement)Generates a String locator which uniquely identifies the target element.StringgetPathForElement(com.google.gwt.user.client.Element targetElement)Deprecated.As of 7.2, call and overridegetPathForElement(Element)insteadbooleanisValidForLegacyLocator(String path)Check if a given selector is valid for LegacyLocatorStrategy.
-
-
-
Constructor Detail
-
ComponentLocator
public ComponentLocator(ApplicationConnection client)
Construct a ComponentLocator for the given ApplicationConnection.- Parameters:
client- ApplicationConnection instance for the application.
-
-
Method Detail
-
getPathForElement
@Deprecated public String getPathForElement(com.google.gwt.user.client.Element targetElement)
Deprecated.As of 7.2, call and overridegetPathForElement(Element)insteadGenerates a String locator which uniquely identifies the target element. ThegetElementByPath(String)method can be used for the inverse operation, i.e. locating an element based on the return value from this method.Note that getElementByPath(getPathForElement(element)) == element is not always true as #getPathForElement(Element) can return a path to another element if the widget determines an action on the other element will give the same result as the action on the target element.
- Parameters:
targetElement- The element to generate a path for.- Returns:
- A String locator that identifies the target element or null if a String locator could not be created.
- Since:
- 5.4
-
getPathForElement
public String getPathForElement(com.google.gwt.dom.client.Element targetElement)
Generates a String locator which uniquely identifies the target element. ThegetElementByPath(String)method can be used for the inverse operation, i.e. locating an element based on the return value from this method.Note that getElementByPath(getPathForElement(element)) == element is not always true as #getPathForElement(Element) can return a path to another element if the widget determines an action on the other element will give the same result as the action on the target element.
- Parameters:
targetElement- The element to generate a path for.- Returns:
- A String locator that identifies the target element or null if a String locator could not be created.
- Since:
- 7.2
-
getElementByPath
public com.google.gwt.user.client.Element getElementByPath(String path)
Locates an element using a String locator (path) which identifies a DOM element. ThegetPathForElement(Element)method can be used for the inverse operation, i.e. generating a string expression for a DOM element.- Parameters:
path- The String locator which identifies the target element.- Returns:
- The DOM element identified by
pathor null if the element could not be located. - Since:
- 5.4
-
getElementsByPath
public com.google.gwt.core.client.JsArray<com.google.gwt.dom.client.Element> getElementsByPath(String path)
Locates elements using a String locator (path) which identifies DOM elements.- Parameters:
path- The String locator which identifies target elements.- Returns:
- The JavaScriptArray of DOM elements identified by
pathor empty array if elements could not be located. - Since:
- 7.2
-
getElementsByPathStartingAt
public com.google.gwt.core.client.JsArray<com.google.gwt.dom.client.Element> getElementsByPathStartingAt(String path, com.google.gwt.dom.client.Element root)
Locates elements using a String locator (path) which identifies DOM elements. The path starts from the specified root element.- Parameters:
path- The path of elements to be foundroot- The root element where the path is anchored- Returns:
- The JavaScriptArray of DOM elements identified by
pathor empty array if elements could not be located. - Since:
- 7.2
- See Also:
getElementByPath(String)
-
getElementByPathStartingAt
public com.google.gwt.user.client.Element getElementByPathStartingAt(String path, com.google.gwt.dom.client.Element root)
Locates an element using a String locator (path) which identifies a DOM element. The path starts from the specified root element.- Parameters:
path- The path of the element to be foundroot- The root element where the path is anchored- Returns:
- The DOM element identified by
pathor null if the element could not be located. - Since:
- 7.2
- See Also:
getElementByPath(String)
-
getClient
public ApplicationConnection getClient()
Returns theApplicationConnectionused by this locator.This method is primarily for internal use by the framework.
- Returns:
- the application connection
-
isValidForLegacyLocator
public boolean isValidForLegacyLocator(String path)
Check if a given selector is valid for LegacyLocatorStrategy.- Parameters:
path- Vaadin selector path- Returns:
- true if passes path validation with LegacyLocatorStrategy
-
-