Interface MiniWebDriver
-
- All Implemented Interfaces:
public interface MiniWebDriver
-
-
Method Summary
Modifier and Type Method Description abstract UnitnavigateTo(String url)abstract Stringurl()abstract List<Map<String, String>>getCookies()abstract UnitdeleteCookies(String name, String url, String domain, String path)abstract UnitclearBrowserCookies()abstract LongwaitForSelector(String selector, Long timeoutMillis)abstract DurationwaitForNavigation(String oldUrl)abstract LongwaitForNavigation(String oldUrl, Long timeoutMillis)abstract Booleanexists(String selector)abstract BooleanisHidden(String selector)abstract BooleanisVisible(String selector)abstract Booleanvisible(String selector)abstract BooleanisChecked(String selector)abstract UnitbringToFront()abstract Unitfocus(String selector)abstract Unittype(String selector, String text)abstract Unitfill(String selector, String text)abstract Unitpress(String selector, String key)abstract Unitclick(String selector, Integer count)abstract UnitclickTextMatches(String selector, String pattern, Integer count)abstract UnitclickMatches(String selector, String attrName, String pattern, Integer count)abstract StringclickNthAnchor(Integer n, String rootSelector)abstract Unitcheck(String selector)abstract Unituncheck(String selector)abstract UnitscrollTo(String selector)abstract UnitscrollDown(Integer count)abstract UnitscrollUp(Integer count)abstract UnitscrollToTop()abstract UnitscrollToBottom()abstract UnitscrollToMiddle(Double ratio)abstract UnitscrollToScreen(Double screenNumber)abstract UnitmouseWheelDown(Integer count, Double deltaX, Double deltaY, Long delayMillis)abstract UnitmouseWheelUp(Integer count, Double deltaX, Double deltaY, Long delayMillis)abstract UnitmoveMouseTo(Double x, Double y)abstract UnitmoveMouseTo(String selector, Integer deltaX, Integer deltaY)abstract UnitdragAndDrop(String selector, Integer deltaX, Integer deltaY)abstract StringouterHTML()abstract StringouterHTML(String selector)abstract StringselectFirstTextOrNull(String selector)abstract List<String>selectTextAll(String selector)abstract StringselectFirstAttributeOrNull(String selector, String attrName)abstract Map<String, String>selectAttributes(String selector)abstract List<String>selectAttributeAll(String selector, String attrName, Integer start, Integer limit)abstract UnitsetAttribute(String selector, String attrName, String attrValue)abstract UnitsetAttributeAll(String selector, String attrName, String attrValue)abstract StringselectFirstPropertyValueOrNull(String selector, String propName)abstract List<String>selectPropertyValueAll(String selector, String propName, Integer start, Integer limit)abstract UnitsetProperty(String selector, String propName, String propValue)abstract UnitsetPropertyAll(String selector, String propName, String propValue)abstract List<Hyperlink>selectHyperlinks(String selector, Integer offset, Integer limit)abstract List<String>selectImages(String selector, Integer offset, Integer limit)abstract Objectevaluate(String expression)abstract ObjectevaluateValue(String expression)abstract StringcaptureScreenshot()abstract StringcaptureScreenshot(String selector)abstract Unitdelay(Long millis)-
-
Method Detail
-
navigateTo
abstract Unit navigateTo(String url)
- Parameters:
url- URL to navigate page to.
-
getCookies
abstract List<Map<String, String>> getCookies()
- Returns:
The cookies of the current page.
-
deleteCookies
abstract Unit deleteCookies(String name, String url, String domain, String path)
- Parameters:
name- Name of the cookies to remove.url- If specified, deletes all the cookies with the given name where domain and path match provided URL.domain- If specified, deletes only cookies with the exact domain.path- If specified, deletes only cookies with the exact path.
-
clearBrowserCookies
abstract Unit clearBrowserCookies()
-
waitForSelector
abstract Long waitForSelector(String selector, Long timeoutMillis)
- Parameters:
timeoutMillis- The maximum time to wait for the element to become present.- Returns:
The remaining time until timeout when the element becomes present.
-
waitForNavigation
abstract Duration waitForNavigation(String oldUrl)
-
waitForNavigation
abstract Long waitForNavigation(String oldUrl, Long timeoutMillis)
- Parameters:
timeoutMillis- The maximum time to wait for the url to change.
-
exists
abstract Boolean exists(String selector)
- Parameters:
selector-The selector of the element to check.
- Returns:
Whether the element exists.
-
isHidden
abstract Boolean isHidden(String selector)
- Parameters:
selector-The selector of the element to check.
- Returns:
Whether the element is hidden.
-
isVisible
abstract Boolean isVisible(String selector)
- Parameters:
selector-The selector of the element to check.
- Returns:
Whether the element is visible.
-
visible
abstract Boolean visible(String selector)
- Parameters:
selector-The selector of the element to check.
- Returns:
Whether the element is visible.
-
isChecked
abstract Boolean isChecked(String selector)
- Parameters:
selector-The selector of the element to check.
- Returns:
Whether the element is checked.
-
bringToFront
abstract Unit bringToFront()
-
focus
abstract Unit focus(String selector)
- Parameters:
selector-A selector of an element to focus. If there are multiple elements satisfying the selector, the first will be focused.
-
type
abstract Unit type(String selector, String text)
- Parameters:
selector-A selector of an element to focus. If there are multiple elements satisfying the selector, the first will be focused.
text- The text to insert.
-
fill
abstract Unit fill(String selector, String text)
- Parameters:
selector-A selector of an element to focus, and then fill text into it. If there are multiple elements satisfying the selector, the first will be focused.
text- The text to fill.
-
press
abstract Unit press(String selector, String key)
- Parameters:
selector-A selector of an element to focus, and then press a key. If there are multiple elements satisfying the selector, the first will be focused.
key-A key to press. The key can be a single character, a key name, or a combination of both.
-
click
abstract Unit click(String selector, Integer count)
- Parameters:
selector-A selector of an element to focus. If there are multiple elements satisfying the selector, the first will be focused.
count- The number of times to click.
-
clickTextMatches
abstract Unit clickTextMatches(String selector, String pattern, Integer count)
- Parameters:
selector-A selector of an element to focus. If there are multiple elements satisfying the selector, the first will be focused.
pattern- The pattern to match the text content.count- The number of times to click.
-
clickMatches
abstract Unit clickMatches(String selector, String attrName, String pattern, Integer count)
- Parameters:
selector-A selector of an element to focus. If there are multiple elements satisfying the selector, the first will be focused.
attrName- The attribute name to match.pattern- The pattern to match the text content.count- The number of times to click.
-
clickNthAnchor
abstract String clickNthAnchor(Integer n, String rootSelector)
- Parameters:
n- The index of the anchor element to click (0-based).rootSelector- The CSS selector of the root element to search within (default is "body").- Returns:
The href attribute of the clicked anchor element, or null if the element does not exist.
-
check
abstract Unit check(String selector)
- Parameters:
selector-A selector of an element to check. If there are multiple elements satisfying the selector, the first will be checked.
-
uncheck
abstract Unit uncheck(String selector)
- Parameters:
selector-A selector of an element to uncheck. If there are multiple elements satisfying the selector, the first will be focused.
-
scrollTo
abstract Unit scrollTo(String selector)
- Parameters:
selector-A selector to search for element to scroll to. If there are multiple elements satisfying the selector, the first will be selected.
-
scrollDown
abstract Unit scrollDown(Integer count)
- Parameters:
count- The times to scroll down.
-
scrollToTop
abstract Unit scrollToTop()
-
scrollToBottom
abstract Unit scrollToBottom()
-
scrollToMiddle
abstract Unit scrollToMiddle(Double ratio)
- Parameters:
ratio- The ratio of the page to scroll to, 0.0 means the top, 1.0 means the bottom.
-
scrollToScreen
abstract Unit scrollToScreen(Double screenNumber)
- Parameters:
screenNumber- The screen number of the page to scroll to (0-based).
-
mouseWheelDown
abstract Unit mouseWheelDown(Integer count, Double deltaX, Double deltaY, Long delayMillis)
- Parameters:
count- The times to wheel down.deltaX- The distance to wheel horizontally.deltaY- The distance to wheel vertically.delayMillis- The delay time in milliseconds.
-
mouseWheelUp
abstract Unit mouseWheelUp(Integer count, Double deltaX, Double deltaY, Long delayMillis)
- Parameters:
count- The times to wheel up.deltaX- The distance to wheel horizontally.deltaY- The distance to wheel vertically.delayMillis- The delay time in milliseconds.
-
moveMouseTo
abstract Unit moveMouseTo(Double x, Double y)
- Parameters:
x- The x coordinate to move to.y- The y coordinate to move to.
-
moveMouseTo
abstract Unit moveMouseTo(String selector, Integer deltaX, Integer deltaY)
- Parameters:
deltaX- The distance to the left of the element.deltaY- The distance to the top of the element.
-
dragAndDrop
abstract Unit dragAndDrop(String selector, Integer deltaX, Integer deltaY)
- Parameters:
selector-selector of the element to drag from.
deltaX- The distance to drag horizontally.deltaY- The distance to drag vertically.
-
outerHTML
abstract String outerHTML(String selector)
- Parameters:
selector- The selector to locate the node.- Returns:
The HTML markup of the node.
-
selectFirstTextOrNull
abstract String selectFirstTextOrNull(String selector)
- Parameters:
selector- The selector to locate the node.- Returns:
The text content of the node.
-
selectTextAll
abstract List<String> selectTextAll(String selector)
- Parameters:
selector- The selector to locate the nodes.- Returns:
The text contents of the nodes.
-
selectFirstAttributeOrNull
abstract String selectFirstAttributeOrNull(String selector, String attrName)
- Parameters:
selector- The selector to locate the node.attrName- The attribute name to retrieve.- Returns:
The attribute value of the node.
-
selectAttributes
abstract Map<String, String> selectAttributes(String selector)
- Parameters:
selector- The selector to locate the nodes.- Returns:
The attribute pairs of the nodes.
-
selectAttributeAll
abstract List<String> selectAttributeAll(String selector, String attrName, Integer start, Integer limit)
- Parameters:
selector- The selector to locate the nodes.attrName- The attribute name to retrieve.start- The offset of the first node to select.limit- The maximum number of nodes to select.- Returns:
The attribute values of the nodes.
-
setAttribute
abstract Unit setAttribute(String selector, String attrName, String attrValue)
- Parameters:
selector- The CSS query to select an element.attrName- The attribute name to set.attrValue- The attribute value to set.
-
setAttributeAll
abstract Unit setAttributeAll(String selector, String attrName, String attrValue)
- Parameters:
selector- The CSS query to select elements.attrName- The attribute name to set.attrValue- The attribute value to set.
-
selectFirstPropertyValueOrNull
abstract String selectFirstPropertyValueOrNull(String selector, String propName)
- Parameters:
selector- The selector to locate the node.propName- The property name to retrieve.- Returns:
The property value of the node.
-
selectPropertyValueAll
abstract List<String> selectPropertyValueAll(String selector, String propName, Integer start, Integer limit)
- Parameters:
selector- The selector to locate the nodes.propName- The property name to retrieve.start- The offset of the first node to select.limit- The maximum number of nodes to select.- Returns:
The property values of the nodes.
-
setProperty
abstract Unit setProperty(String selector, String propName, String propValue)
- Parameters:
selector- The CSS query to select an element.propName- The property name to set.propValue- The property value to set.
-
setPropertyAll
abstract Unit setPropertyAll(String selector, String propName, String propValue)
- Parameters:
selector- The CSS query to select elements.propName- The property name to set.propValue- The property value to set.
-
selectHyperlinks
abstract List<Hyperlink> selectHyperlinks(String selector, Integer offset, Integer limit)
- Parameters:
selector- The CSS query to select elements.offset- The offset of the first element to select.limit- The maximum number of elements to select.- Returns:
The hyperlinks in the elements.
-
selectImages
abstract List<String> selectImages(String selector, Integer offset, Integer limit)
- Parameters:
selector- The CSS query to select elements.offset- The offset of the first element to select.limit- The maximum number of elements to select.- Returns:
The image URLs.
-
evaluate
abstract Object evaluate(String expression)
- Parameters:
expression- Javascript expression to evaluate- Returns:
Remote object value in case of primitive values or null.
-
evaluateValue
abstract Object evaluateValue(String expression)
- Parameters:
expression- Javascript expression to evaluate- Returns:
Remote object value in case of primitive values or JSON values (if it was requested).
-
captureScreenshot
abstract String captureScreenshot()
- Returns:
The screenshot of the element in base64 format.
-
captureScreenshot
abstract String captureScreenshot(String selector)
- Parameters:
selector- The selector of the element to capture.- Returns:
The screenshot of the element in base64 format.
-
-
-
-