Class VaadinFinderLocatorStrategy
- java.lang.Object
-
- com.vaadin.client.componentlocator.VaadinFinderLocatorStrategy
-
- All Implemented Interfaces:
LocatorStrategy
public class VaadinFinderLocatorStrategy extends Object implements LocatorStrategy
The VaadinFinder locator strategy implements an XPath-like syntax for locating elements in Vaadin applications. This is used in the new VaadinFinder API in TestBench 4. Examples of the supported syntax:- Find the third text field in the DOM:
//VTextField[2] - Find the second button inside the first vertical layout:
//VVerticalLayout/VButton[1] - Find the first column on the third row of the "Accounts" table:
//VScrollTable[caption="Accounts"]#row[2]/col[0]
- Since:
- 7.2
- Author:
- Vaadin Ltd
-
-
Field Summary
Fields Modifier and Type Field Description static StringSUBPART_SEPARATOR
-
Constructor Summary
Constructors Constructor Description VaadinFinderLocatorStrategy(ApplicationConnection clientConnection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.gwt.dom.client.ElementgetElementByPath(String path)Locates an element using a String locator (path) which identifies a DOM element.com.google.gwt.dom.client.ElementgetElementByPathStartingAt(String path, com.google.gwt.dom.client.Element root)Locates an element using a String locator (path) which identifies a DOM element.List<com.google.gwt.dom.client.Element>getElementsByPath(String path)Locates all elements that match a String locator (path) which identifies DOM elements.List<com.google.gwt.dom.client.Element>getElementsByPathStartingAt(String path, com.google.gwt.dom.client.Element root)Locates all elements that match 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.booleanvalidatePath(String path)Test the given input path for formatting errors.
-
-
-
Field Detail
-
SUBPART_SEPARATOR
public static final String SUBPART_SEPARATOR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
VaadinFinderLocatorStrategy
public VaadinFinderLocatorStrategy(ApplicationConnection clientConnection)
-
-
Method Detail
-
getPathForElement
public String getPathForElement(com.google.gwt.dom.client.Element targetElement)
Generates a String locator which uniquely identifies the target element. TheLocatorStrategy.getElementByPath(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.
- Specified by:
getPathForElementin interfaceLocatorStrategy- 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.
-
getElementsByPath
public List<com.google.gwt.dom.client.Element> getElementsByPath(String path)
Locates all elements that match a String locator (path) which identifies DOM elements. This functionality is limited inLegacyLocatorStrategy.- Specified by:
getElementsByPathin interfaceLocatorStrategy- Parameters:
path- The String locator which identifies target elements.- Returns:
- List that contains all matched elements. Empty list if none found.
-
getElementByPath
public com.google.gwt.dom.client.Element getElementByPath(String path)
Locates an element using a String locator (path) which identifies a DOM element. TheLocatorStrategy.getPathForElement(Element)method can be used for the inverse operation, i.e. generating a string expression for a DOM element.- Specified by:
getElementByPathin interfaceLocatorStrategy- 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.
-
getElementByPathStartingAt
public com.google.gwt.dom.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.- Specified by:
getElementByPathStartingAtin interfaceLocatorStrategy- Parameters:
path- The String locator which identifies the target element.root- The element that is at the root of the path.- Returns:
- The DOM element identified by
pathor null if the element could not be located. - See Also:
LocatorStrategy.getElementByPath(String)
-
getElementsByPathStartingAt
public List<com.google.gwt.dom.client.Element> getElementsByPathStartingAt(String path, com.google.gwt.dom.client.Element root)
Locates all elements that match a String locator (path) which identifies DOM elements. The path starts from the specified root element. This functionality is limited inLegacyLocatorStrategy.- Specified by:
getElementsByPathStartingAtin interfaceLocatorStrategy- Parameters:
path- The String locator which identifies target elements.root- The element that is at the root of the path.- Returns:
- List that contains all matched elements. Empty list if none found.
- See Also:
LocatorStrategy.getElementsByPath(String)
-
validatePath
public boolean validatePath(String path)
Description copied from interface:LocatorStrategyTest the given input path for formatting errors. If a given path can not be validated, the locator strategy will not be attempted.- Specified by:
validatePathin interfaceLocatorStrategy- Parameters:
path- a locator path expression- Returns:
- true, if the implementing class can process the given path, otherwise false
-
-