Package dev.comfast.cf
Interface CfLocator
- All Known Subinterfaces:
CfFoundLocator
- All Known Implementing Classes:
CfAbstractLocator,FoundElement,SeleniumLocator
public interface CfLocator
-
Method Summary
Modifier and TypeMethodDescriptionget sub-locator related to current onevoidclear()Clear given input/textarea/select/checkboxvoidclick()Click on elementintcount()voidDrag current element onto other elementExecutes JavaScript code, where "this" is current elementbooleanexists()find()Force find action.voidfocus()Focus on element using JSvoidforEach(Consumer<CfFoundLocator> func) Iterate thorough all elements matched by locatorgetAttribute(String name) getCssValue(String name) getText()getValue()booleanvoidhover()Hover mouse on elementboolean<T> List<T>map(Function<CfFoundLocator, T> func) Does mapping against each element found by locatornth(int nth) nth element found by locatorvoidsetChecked(boolean state) Check/uncheck checkboxvoidGeneric set value of element.voidWait for given condition matchdefault voidWait fo given condition not matchvoidtap()Tap gesture on elementtryFind()Force find action, doesn't throw exception.voidType keys into elementvoidWait for given function return truth value (true, 1, non null object etc.)
-
Method Details
-
$
get sub-locator related to current one- Returns:
- Cfloctor
-
find
CfFoundLocator find()Force find action. If you want only check existence of element useexists()method.- Returns:
- Found element.
- Throws:
ElementFindFail- if element not found
-
tryFind
Optional<CfFoundLocator> tryFind()Force find action, doesn't throw exception. If you want only check existence of element useexists()method.- Returns:
- force locator find action.
- Throws:
ElementFindFail- if element not found
-
hasClass
- Parameters:
cssClass- name- Returns:
- if element have given css class
-
getText
String getText()- Returns:
- text of element
-
innerHtml
String innerHtml()- Returns:
- inner html of element
-
outerHtml
String outerHtml()- Returns:
- outer html of element
-
getValue
String getValue()- Returns:
- value of element
-
getAttribute
- Returns:
- javascript attribute of element
-
getCssValue
- Parameters:
name- eg. color, opacity, etc.- Returns:
- css value of given name
-
exists
boolean exists()- Returns:
- true if element exists in DOM
-
getTagName
String getTagName()- Returns:
- html tag name
-
isDisplayed
boolean isDisplayed()- Returns:
- true if element is visible, not throw if element not found - just return false
-
click
void click()Click on element -
tap
void tap()Tap gesture on element -
focus
void focus()Focus on element using JS -
hover
void hover()Hover mouse on element -
dragTo
Drag current element onto other element -
setValue
Generic set value of element. Should work on input, textarea, select, etc.- Parameters:
value- to set
-
setChecked
void setChecked(boolean state) Check/uncheck checkbox- Parameters:
state- true- check, false - uncheck
-
clear
void clear()Clear given input/textarea/select/checkbox -
type
Type keys into element- Parameters:
keys- keyboard input, can use special keys in format: {Ctrl}, {Ctrl+Shift+L}, {Shift+some text} etc.
-
count
int count()- Returns:
- number of elements found by locator
-
executeJs
Executes JavaScript code, where "this" is current element- Parameters:
script- JS Codeargs- arguments for JS code- Returns:
- result of JS code
-
map
Does mapping against each element found by locator- Type Parameters:
T- mapping result type- Parameters:
func- mapping function, eg. locator -> locator.getText()- Returns:
- list of mapped values
-
forEach
Iterate thorough all elements matched by locator- Parameters:
func- function, eg. locator -> locator.setValue("abc")
-
nth
nth element found by locator- Parameters:
nth- index starting of 1- Returns:
- CfLocator
-
waitFor
Wait for given function return truth value (true, 1, non null object etc.)locator.waitFor(el -> el.count() > 0, 3000); locator.waitFor(el -> el.getText().equals("some text"), 60_000);- Parameters:
timeoutMs- timeout in milliseconds
-
should
Wait for given condition match -
shouldNot
Wait fo given condition not match
-