public class UIFinder extends Object
components
by ID. An instance of this class is provided for you, just read the com.whitestein.lsps.web.vaadin.tests.LspsVaadinTestCase#screen property.
Following is true for all find methods found in this class:
-- Only children and/or descendants of this component are searched.
-- Only visible components are found successfully.
These functions finds UI components by searching for a DOM element in the current browser DOM tree. When a LSPS UIComponent is
invisible, its element (div or other) is removed from the DOM tree. This is why this function can't find invisible components.Modifier and Type | Field and Description |
---|---|
protected SearchContext |
context
The search context to search in, either the entire page (WebDriver) or a component.
|
Constructor and Description |
---|
UIFinder(SearchContext context,
WebDriver webDriver,
boolean root) |
Modifier and Type | Method and Description |
---|---|
<T extends AbstractElement> |
$(Class<T> clazz)
Prepare a
ElementQuery instance to use for locating components on
the client. |
UIActions |
actions() |
void |
clickButton(String id)
Deprecated.
|
boolean |
contains(String id)
Checks if there is any visible component with given ID, which is child or descendant of this component.
|
protected By |
createIdLocator(String id) |
List<UIComponent> |
findAllByAttributeValue(String attribute,
String value)
Finds all elements that have attribute set to given value.
|
List<UIComponent> |
findAllByClassname(String className)
Finds all elements styled with css className.
|
List<UIComponent> |
findAllByFormId(String id)
Finds elements with given lsps form id.
|
List<UIComponent> |
findAllById(String id)
Finds element with given html id.
|
List<UIComponent> |
findAllByIdPrefix(String prefix)
Finds all elements whose html id starts with given prefix.
|
List<UIComponent> |
findAllByLspsId(String id)
Finds all elements rendered from component with given lsps id.
|
List<UIComponent> |
findAllByTextContent(String content)
Finds all elements containing content text.
|
List<UIComponent> |
findAllByXpath(String xpath)
Finds all elements by xpath.
|
UIComponent |
findByAttributeValue(String attribute,
String value)
Finds element by attribute value.
|
UIComponent |
findByClassname(String className)
Finds an element styled with css className.
|
UIComponent |
findByFormId(String id)
Finds element with given form id.
|
UIComponent |
findById(String id)
Finds element with given html id.
|
UIComponent |
findByIdPrefix(String prefix)
Finds element whose html id starts with given prefix.
|
UIComponent |
findByLspsId(String id)
Finds element by given lsps id.
|
UIComponent |
findByTextContent(String content)
Finds element containing content text.
|
UIComponent |
findByXpath(String xpath)
Finds element by xpath.
|
LspsCaption |
findCaptionByTextContent(String content)
Finds caption with the exact text.
|
WebElement |
findElement(By by) |
List<WebElement> |
findElements(By by) |
UIComponent |
findNthByTag(int nth,
String tag)
Finds nth instance of the html tag.
|
WebDriver |
getDriver() |
protected LspsCommandExecutor |
getLspsCommandExecutor() |
String |
toString() |
void |
waitForVaadin()
Should be invoked after every potential server contact.
|
protected List<WebElement> |
webElementsByExactTextContent(String content) |
protected List<WebElement> |
webElementsByFormId(String id) |
protected List<WebElement> |
webElementsById(String id) |
protected List<WebElement> |
webElementsByIdPrefix(String prefix) |
protected List<WebElement> |
webElementsByLspsFormId(String id) |
protected List<WebElement> |
webElementsByLspsId(String id)
Finds all components matching given ID
|
protected List<WebElement> |
webElementsByTextContent(String content) |
protected List<WebElement> |
webElementsByXpath(String xpath) |
protected final SearchContext context
public UIFinder(SearchContext context, WebDriver webDriver, boolean root)
protected List<WebElement> webElementsByLspsId(String id)
id
- the component ID (your custom ID, not the modelingID).public final boolean contains(String id)
id
- the component ID (your custom ID, not the modelingID).public final UIComponent findByLspsId(String id)
findAllByLspsId(String)
if there may be multiple html nodes rendered from one lsps
component.
Lsps id is an identifier used to reference the component in expressions. For example, if
`userName.getCaption()` is valid lsps expression, then 'userName' is lsps id. Lsps id is
configured in PDS inside detail tab of component properties view.
Note: id of html node corresponding to lsps component has lsps id as prefix.id
- the id, not null. your custom ID, not the modelingIDNoSuchElementException
- if there are no visible elements with given IDIllegalArgumentException
- if multiple elements match given ID.public final List<UIComponent> findAllByLspsId(String id)
id
- the id, not null. your custom ID, not the modelingIDpublic UIComponent findByClassname(String className)
className
- - css class to look for.public List<UIComponent> findAllByClassname(String className)
className
- - css class to look for.public UIComponent findNthByTag(int nth, String tag)
nth
- - which occurrence of html tag to returntag
- - html tag to look for.public UIComponent findByTextContent(String content)
content
- - text to look for. Case sensitive.public List<UIComponent> findAllByTextContent(String content)
content
- - text to look for. Case sensitive.protected By createIdLocator(String id)
public UIComponent findById(String id)
id
- - full id. Examples:
estimatesTable__Lwxl4P9aEeaK3drkZpNeUw
estimatesTable__Lwxl4P9aEeaK3drkZpNeUw__copy__3public List<UIComponent> findAllById(String id)
id
- - full id. Examples:
estimatesTable__Lwxl4P9aEeaK3drkZpNeUw
estimatesTable__Lwxl4P9aEeaK3drkZpNeUw__copy__3public UIComponent findByFormId(String id)
id
- - form id. Examples:
reusable_call__Lwxl4P9aEeaK3drkZpNeUw
call_that_with_parameter__Lwxl4P9aEeaK3drkZpNeUw__copy__3public List<UIComponent> findAllByFormId(String id)
id
- - full id. Examples:
reusable_call__Lwxl4P9aEeaK3drkZpNeUw
call_that_with_parameter__Lwxl4P9aEeaK3drkZpNeUw__copy__3public UIComponent findByIdPrefix(String prefix)
prefix
- - id prefix.public List<UIComponent> findAllByIdPrefix(String prefix)
prefix
- - id prefix.public UIComponent findByXpath(String xpath)
xpath
- public List<UIComponent> findAllByXpath(String xpath)
xpath
- public UIComponent findByAttributeValue(String attribute, String value)
attribute
- - attribute name.value
- - valuepublic List<UIComponent> findAllByAttributeValue(String attribute, String value)
attribute
- - attribute name.value
- - value@Deprecated public void clickButton(String id)
find(id).as().button().click()
or
actions().clickButton()
.id
- the id, not null. your custom ID, not the modelingIDpublic WebElement findElement(By by)
public List<WebElement> findElements(By by)
public void waitForVaadin()
RuntimeException
is thrown.protected LspsCommandExecutor getLspsCommandExecutor()
public <T extends AbstractElement> <any> $(Class<T> clazz)
ElementQuery
instance to use for locating components on
the client. The returned object can be manipulated to uniquely identify
the sought-after object. If this function gets called through an element,
it uses the element as its search context. Otherwise the search context
is the driver.T
- clazz
- ElementQuery
instanceprotected List<WebElement> webElementsByExactTextContent(String content)
public LspsCaption findCaptionByTextContent(String content)
content
- - text to look for. Case sensitive.public WebDriver getDriver()
public UIActions actions()
Copyright © 2007-2020 Whitestein Technologies. All Rights Reserved.