Package io.karatelabs.driver
Class BaseElement
java.lang.Object
io.karatelabs.driver.BaseElement
- All Implemented Interfaces:
Element,io.karatelabs.js.ObjectLike,io.karatelabs.js.SimpleObject
- Direct Known Subclasses:
W3cElement
Locator-based Element implementation that delegates all operations to a Driver.
This is the default implementation used by all backends (CDP, W3C WebDriver, etc.).
Operations are performed by passing the locator to the Driver, which handles
backend-specific execution (JS eval for CDP, HTTP calls for W3C, etc.).
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Driverprotected final booleanprotected final StringFields inherited from interface io.karatelabs.js.SimpleObject
logger, TO_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidclear()click()The closest ancestor (or self) matching the given CSS selector.booleanenabled()static BaseElementConstruct an Element whose existence has already been verified by the caller.booleanexists()focus()html()booleanbooleanWhether this element matches the given CSS selector.static BaseElementstatic BaseElementposition()position(boolean relative) retry()retry(int count) retry(int count, int interval) scroll()select(int index) submit()text()toString()value()waitFor()waitForText(String expected) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.karatelabs.js.ObjectLike
getMember, getPrototype, isExtensible, isFrozen, isOwnProperty, isSealed, putMember, removeMember, setExtensible, setFrozen, setSealedMethods inherited from interface io.karatelabs.js.SimpleObject
getMember, jsKeys, jsToString, putMember, removeMember, toMap
-
Field Details
-
driver
-
locator
-
exists
protected final boolean exists
-
-
Constructor Details
-
BaseElement
-
-
Method Details
-
of
-
optional
-
existing
Construct an Element whose existence has already been verified by the caller. Skips the exists() round-trip, which also avoids re-entering the driver at a moment when it may be unable to evaluate JS — e.g. after click() opened a blocking alert/confirm/prompt dialog. -
exists
public boolean exists() -
isPresent
public boolean isPresent() -
getLocator
- Specified by:
getLocatorin interfaceElement
-
text
-
html
-
innerHtml
-
value
-
attribute
-
property
-
enabled
public boolean enabled() -
position
-
position
-
click
-
focus
-
clear
-
input
-
value
-
select
-
select
-
scroll
-
highlight
-
submit
-
locate
-
locateAll
-
closest
Description copied from interface:ElementThe closest ancestor (or self) matching the given CSS selector. Mirrors the nativeElement.closest()DOM API — robust to markup shuffling, preferred over counting parent hops. -
matches
Description copied from interface:ElementWhether this element matches the given CSS selector. Mirrors the nativeElement.matches()DOM API. -
script
-
waitFor
-
waitForText
- Specified by:
waitForTextin interfaceElement
-
waitForEnabled
- Specified by:
waitForEnabledin interfaceElement
-
waitUntil
-
retry
-
retry
-
retry
-
jsGet
- Specified by:
jsGetin interfaceio.karatelabs.js.SimpleObject
-
assertExists
protected void assertExists() -
toString
-