public abstract static class RS.XPATH
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
RS.XPATH.ARIA
Defines arrays of search-conditions (according to ARIA Roles)
to be appended to
DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static class |
RS.XPATH.HTML
Defines arrays of search-conditions for HTML Controls
to be appended to
DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static class |
RS.XPATH.SAP
Defines arrays of search-conditions for SAPUI5 controls
to be appended to
DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ALL_ELEMENTS_PREFIX
// represents the path to all elements on the page,
it should be appended with real tag name or search-condition, for example "//input" will represent
all input tags on the page.
|
static java.lang.String |
AND
and
|
static java.lang.String[] |
BUTTON
Contains items from
RS.XPATH.HTML.BUTTON , RS.XPATH.ARIA.BUTTON and RS.XPATH.SAP.BUTTON An array of search-conditions to be appended to DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static java.lang.String[] |
CHECKBOX
Contains items from
RS.XPATH.HTML.CHECKBOX , RS.XPATH.ARIA.CHECKBOX and RS.XPATH.SAP.CHECKBOX An array of search-conditions to be appended to DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching checkbox.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static java.lang.String[] |
COLOR
Contains items from
RS.XPATH.HTML.COLOR An array of search-conditions to be appended to DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching color picker.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static java.lang.String[] |
COMBOBOX
Contains items from
RS.XPATH.HTML.COMBOBOX , RS.XPATH.ARIA.COMBOBOX and RS.XPATH.SAP.COMBOBOX An array of search-conditions to be appended to DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching combobox.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static java.lang.String[] |
DATETIME
Contains items from
RS.XPATH.HTML.DATETIME An array of search-conditions to be appended to DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching date-time input box.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static java.lang.String |
DESCENDANTS_PREFIX
.// represents the path to children, grand-children etc.
|
static java.lang.String[] |
EDITBOX
Contains items from
RS.XPATH.HTML.EDITBOX , RS.XPATH.ARIA.EDITBOX and RS.XPATH.SAP.EDITBOX An array of search-conditions to be appended to DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static java.lang.String |
END
]
|
static java.lang.String[] |
FILE
Contains items from
RS.XPATH.HTML.FILE An array of search-conditions to be appended to DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching file picker.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static java.lang.String[] |
IMAGE
Contains items from
RS.XPATH.HTML.IMAGE , RS.XPATH.ARIA.IMAGE and RS.XPATH.SAP.IMAGE An array of search-conditions to be appended to DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching image.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static java.lang.String[] |
LIST
Contains items from
RS.XPATH.HTML.LIST , RS.XPATH.ARIA.LISTBOX , RS.XPATH.ARIA.LIST and RS.XPATH.SAP.LIST An array of search-conditions to be appended to DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching list.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static java.lang.String |
MATCHING_ALL_START
//*[, it is used as beginning to construct an xpath for searching elements under ENTIRE document.
|
static java.lang.String |
MATCHING_DIV_START
//DIV[, it is used as beginning to construct an xpath for searching DIV elements under ENTIRE document.
|
static java.lang.String |
OR
or used inside one XPATH as logical or, such as input[@type='email' or @type='number']
|
static java.lang.String |
PARENT
.. represents the parent
|
static java.lang.String[] |
RADIO
Contains items from
RS.XPATH.HTML.RADIO , RS.XPATH.ARIA.RADIO and RS.XPATH.SAP.RADIO An array of search-conditions to be appended to DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching radio button.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static java.lang.String[] |
RANGE
Contains items from
RS.XPATH.HTML.RANGE and RS.XPATH.SAP.RANGE An array of search-conditions to be appended to DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching range.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static java.lang.String |
REGEX_OR
| used between multiple XPATH as logical or, such as //book/title | //book/price
|
static java.lang.String |
RELATIVE_MATCHING_ALL_START
.//*[, it is used as beginning to construct an xpath for searching elements under current WebElement.
|
static java.lang.String |
RELATIVE_MATCHING_DIV_START
.//DIV[, it is used as beginning to construct an xpath for searching DIV elements under current WebElement.
|
static java.lang.String[] |
TABLE
Contains items from
RS.XPATH.HTML.TABLE , RS.XPATH.ARIA.TABLE and RS.XPATH.SAP.TABLE An array of search-conditions to be appended to DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching table.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static java.lang.String |
TAG_ANY
* represents any tag name
|
static java.lang.String |
TAG_DIV
DIV tag name
|
static java.lang.String[] |
TREE
Contains items from
RS.XPATH.ARIA.TREE and RS.XPATH.SAP.TREE An array of search-conditions to be appended to DESCENDANTS_PREFIX or ALL_ELEMENTS_PREFIX to form a valid XPATH for searching tree.It serves as parameter of relativeDescendants(String[]) or allDescendants(String[]) |
static java.lang.String |
TRUE_CONDITION
(1=1), an always true condition to concatenate other conditions to create an XPAH for searching.
|
Constructor and Description |
---|
XPATH() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
allDescendants(java.lang.String[] targets)
According to the search conditions, return the xpath to get all matched elements.
|
static java.lang.String |
condition(java.lang.String attribute,
java.lang.String value,
boolean partialMatch) |
static java.lang.String |
conditionContains(java.lang.String attribute,
java.lang.String value) |
static java.lang.String |
conditionForText(java.lang.String text,
boolean partialMatch) |
static java.lang.String |
fromAttribute(java.lang.String attribute,
java.lang.String value,
boolean partial,
boolean relative)
Create an xpath by (attribute, value) for searching webelement within direct and indirect children.
|
static java.lang.String |
fromAttribute(java.lang.String tag,
java.lang.String attribute,
java.lang.String value,
boolean partial,
boolean relative)
Create an xpath by tag's name and (attribute, value) for searching webelement within direct and indirect children.
|
static java.lang.String |
fromText(java.lang.String text,
boolean partial,
boolean relative)
Create an xpath by text for searching webelement within direct and indirect children.
|
static java.lang.String |
fromText(java.lang.String tag,
java.lang.String text,
boolean partial,
boolean relative)
Create an xpath by tag's name and text for searching webelement within direct and indirect children.
|
static java.lang.String |
html()
return '/html'
|
static boolean |
isRootHtml(org.openqa.selenium.SearchContext sc) |
static boolean |
matched(org.openqa.selenium.WebElement element,
java.lang.String type)
Test if the element's type can match what is expected.
|
static java.lang.String |
MATCHING_TAG_START(java.lang.String tag) |
static java.lang.String |
ofType(java.lang.String type) |
protected static java.lang.String |
quote(java.lang.String text)
Add single quote around the text (such as 'text'), and it will be used in XPATH for searching a web element in DOM.
If the text has already been quoted, we simply return it. If the text (such as Tom's) contains single quote, we cannot simply quote the text with single quote, which will cause the error; instead we will use the function concat() to connect each part of the text, such as concat('Tom', "'", 's'). |
static java.lang.String |
RELATIVE_MATCHING_TAG_START(java.lang.String tag) |
static java.lang.String |
relativeDescendants(java.lang.String[] targets)
According to the search conditions, return the xpath to get the relative (to current node) elements.
|
public static final java.lang.String TAG_ANY
public static final java.lang.String TAG_DIV
public static final java.lang.String MATCHING_ALL_START
public static final java.lang.String RELATIVE_MATCHING_ALL_START
public static final java.lang.String MATCHING_DIV_START
public static final java.lang.String RELATIVE_MATCHING_DIV_START
public static final java.lang.String TRUE_CONDITION
public static final java.lang.String END
public static final java.lang.String AND
public static final java.lang.String OR
public static final java.lang.String REGEX_OR
public static final java.lang.String PARENT
public static final java.lang.String DESCENDANTS_PREFIX
public static final java.lang.String ALL_ELEMENTS_PREFIX
public static final java.lang.String[] EDITBOX
RS.XPATH.HTML.EDITBOX
, RS.XPATH.ARIA.EDITBOX
and RS.XPATH.SAP.EDITBOX
DESCENDANTS_PREFIX
or ALL_ELEMENTS_PREFIX
to form a valid XPATH for searching.relativeDescendants(String[])
or allDescendants(String[])
public static final java.lang.String[] BUTTON
RS.XPATH.HTML.BUTTON
, RS.XPATH.ARIA.BUTTON
and RS.XPATH.SAP.BUTTON
DESCENDANTS_PREFIX
or ALL_ELEMENTS_PREFIX
to form a valid XPATH for searching.relativeDescendants(String[])
or allDescendants(String[])
public static final java.lang.String[] COMBOBOX
RS.XPATH.HTML.COMBOBOX
, RS.XPATH.ARIA.COMBOBOX
and RS.XPATH.SAP.COMBOBOX
DESCENDANTS_PREFIX
or ALL_ELEMENTS_PREFIX
to form a valid XPATH for searching combobox.relativeDescendants(String[])
or allDescendants(String[])
public static final java.lang.String[] CHECKBOX
RS.XPATH.HTML.CHECKBOX
, RS.XPATH.ARIA.CHECKBOX
and RS.XPATH.SAP.CHECKBOX
DESCENDANTS_PREFIX
or ALL_ELEMENTS_PREFIX
to form a valid XPATH for searching checkbox.relativeDescendants(String[])
or allDescendants(String[])
public static final java.lang.String[] COLOR
RS.XPATH.HTML.COLOR
DESCENDANTS_PREFIX
or ALL_ELEMENTS_PREFIX
to form a valid XPATH for searching color picker.relativeDescendants(String[])
or allDescendants(String[])
public static final java.lang.String[] DATETIME
RS.XPATH.HTML.DATETIME
DESCENDANTS_PREFIX
or ALL_ELEMENTS_PREFIX
to form a valid XPATH for searching date-time input box.relativeDescendants(String[])
or allDescendants(String[])
public static final java.lang.String[] FILE
RS.XPATH.HTML.FILE
DESCENDANTS_PREFIX
or ALL_ELEMENTS_PREFIX
to form a valid XPATH for searching file picker.relativeDescendants(String[])
or allDescendants(String[])
public static final java.lang.String[] RADIO
RS.XPATH.HTML.RADIO
, RS.XPATH.ARIA.RADIO
and RS.XPATH.SAP.RADIO
DESCENDANTS_PREFIX
or ALL_ELEMENTS_PREFIX
to form a valid XPATH for searching radio button.relativeDescendants(String[])
or allDescendants(String[])
public static final java.lang.String[] RANGE
RS.XPATH.HTML.RANGE
and RS.XPATH.SAP.RANGE
DESCENDANTS_PREFIX
or ALL_ELEMENTS_PREFIX
to form a valid XPATH for searching range.relativeDescendants(String[])
or allDescendants(String[])
public static final java.lang.String[] IMAGE
RS.XPATH.HTML.IMAGE
, RS.XPATH.ARIA.IMAGE
and RS.XPATH.SAP.IMAGE
DESCENDANTS_PREFIX
or ALL_ELEMENTS_PREFIX
to form a valid XPATH for searching image.relativeDescendants(String[])
or allDescendants(String[])
public static final java.lang.String[] LIST
RS.XPATH.HTML.LIST
, RS.XPATH.ARIA.LISTBOX
, RS.XPATH.ARIA.LIST
and RS.XPATH.SAP.LIST
DESCENDANTS_PREFIX
or ALL_ELEMENTS_PREFIX
to form a valid XPATH for searching list.relativeDescendants(String[])
or allDescendants(String[])
public static final java.lang.String[] TREE
RS.XPATH.ARIA.TREE
and RS.XPATH.SAP.TREE
DESCENDANTS_PREFIX
or ALL_ELEMENTS_PREFIX
to form a valid XPATH for searching tree.relativeDescendants(String[])
or allDescendants(String[])
public static final java.lang.String[] TABLE
RS.XPATH.HTML.TABLE
, RS.XPATH.ARIA.TABLE
and RS.XPATH.SAP.TABLE
DESCENDANTS_PREFIX
or ALL_ELEMENTS_PREFIX
to form a valid XPATH for searching table.relativeDescendants(String[])
or allDescendants(String[])
public static final java.lang.String html()
public static java.lang.String MATCHING_TAG_START(java.lang.String tag)
tag
- Ex: span, table, ul, etc..public static java.lang.String RELATIVE_MATCHING_TAG_START(java.lang.String tag)
tag
- Ex: span, table, ul, etc..public static java.lang.String fromText(java.lang.String text, boolean partial, boolean relative)
text
- String, the text of a webelement. can be regex if XPATH2.0partial
- boolean, if the parameter text is part of the webelement's contentrelative
- boolean, if true then searching elements under current WebElement; false then searching elements under ENTIRE document.public static java.lang.String fromText(java.lang.String tag, java.lang.String text, boolean partial, boolean relative)
tag
- String, the name of the tag to find.text
- String, the text of a webelement. can be regex if XPATH2.0partial
- boolean, if the parameter text is part of the webelement's contentrelative
- boolean, if true then searching elements under current WebElement; false then searching elements under ENTIRE document.public static java.lang.String fromAttribute(java.lang.String attribute, java.lang.String value, boolean partial, boolean relative)
attribute
- String, the attribute namevalue
- String, the attribute's value, can be regex if XPATH2.0.partial
- boolean, if the parameter value is part of the webelement's attributerelative
- boolean, if true then searching elements under current WebElement; false then searching elements under ENTIRE document.public static java.lang.String fromAttribute(java.lang.String tag, java.lang.String attribute, java.lang.String value, boolean partial, boolean relative)
attribute
- String, the attribute namevalue
- String, the attribute's value, can be regex if XPATH2.0.partial
- boolean, if the parameter value is part of the webelement's attributerelative
- boolean, if true then searching elements under current WebElement; false then searching elements under ENTIRE document.public static java.lang.String condition(java.lang.String attribute, java.lang.String value, boolean partialMatch)
attribute
- String, the attribute namevalue
- String, the expected value of the attributepartialMatch
- boolean, if the attribute value will be matched partially (considered as a substring)#getCondition(String, boolean)
public static java.lang.String conditionContains(java.lang.String attribute, java.lang.String value)
attribute
- String, the attribute name ending with "contains"value
- String, the expected substring value of the attribute#getCondition(String, boolean)
public static java.lang.String conditionForText(java.lang.String text, boolean partialMatch)
text
- String, the text valuepartialMatch
- boolean, if the text's value will be matched partially (considered as a substring)protected static java.lang.String quote(java.lang.String text)
text
- String, the text of the web element.public static boolean isRootHtml(org.openqa.selenium.SearchContext sc)
public static java.lang.String relativeDescendants(java.lang.String[] targets)
targets
- String[], the search conditionspublic static java.lang.String allDescendants(java.lang.String[] targets)
targets
- String[], the search conditionspublic static java.lang.String ofType(java.lang.String type)
type
- String, represents the WebElement's type, such as "ComboBox", "Button" etc.public static boolean matched(org.openqa.selenium.WebElement element, java.lang.String type)
element
- WebElement, the element to check.type
- String, the expected type, such as EditBox, RadioButton, ComboBox etc.Copyright © SAS Institute. All Rights Reserved.