Element
import {Element} from 'cabbie-async';
A representation of a remote element. You can use it to click on, type text into and check the attributes of.
const element = await driver.activeWindow.getElement('[data-test-id="my-test-element"]');
const elements = await driver.activeWindow.getElements('.some-class-name');
Properties
elementID: string
The selenium id of the element
mouse: Mouse
Utility methods for clicking on the element
touch: Touch
Methods for interacting with the element via touch
Methods
clear(): Promise<void>
Clear the value of an input
getAbsoluteCenter(): Promise<{x:number, y:number}>
Get the absolute center of an element
getAttribute(attribute): Promise<string>
- attribute
- string
Get the value of an attribute.
getCssValue(property): Promise<string>
- property
- string
Query the value of an element's computed CSS property. The CSS property to query should be specified using the CSS property name, not the JavaScript property name (e.g. background-color instead of backgroundColor).
getElement(selector, selectorType?): Promise<Element>
- selector
- string
- selectorType
- SelectorType
Get an element via a selector. Will throw an error if the element does not exist.
getElementByTextContent(textContent, selector?, selectorType?): Promise<Element>
- textContent
- string
- selector
- string
- selectorType
- SelectorType
Get elements by its text content, optionally narrowed down using a selector.
N.B. this is much slower than getting elements by ID or css selector.
getElements(selector, selectorType?): Promise<Array<Element>>
- selector
- string
- selectorType
- SelectorType
Get elements via a selector.
getElementsByTextContent(textContent, selector?, selectorType?): Promise<Array<Element>>
- textContent
- string
- selector
- string
- selectorType
- SelectorType
Get elements by its text content, optionally narrowed down using a selector.
N.B. this is much slower than getting elements by ID or css selector.
getFrame(): Promise<{x:number, y:number, width:number, height:number}>
Get the frame of an element
getPosition(): Promise<{x:number, y:number}>
Get the position of an element
getRelativeCenter(): Promise<{x:number, y:number}>
Get the relative center of an element
getSize(): Promise<{width:number, height:number}>
Get the size of an element
getTagName(): Promise<string>
Get the tag-name of an element.
getText(): Promise<string>
Get the text body of an element.
hasClass(className): Promise<boolean>
- className
- string
Test if the element have a specific class
hasElement(selector, selectorType?): Promise<boolean>
- selector
- string
- selectorType
- SelectorType
Does a specific element exist?
isDisabled(): Promise<boolean>
Return true if the form element is disabled
isDisplayed(): Promise<boolean>
Return true if the element is currently displayed on the page
isEnabled(): Promise<boolean>
Return true if the form element is enabled
isEqual(element): Promise<boolean>
- element
- Element
Return true if the current element is equal to the supplied element
isSelected(): Promise<boolean>
Return true if the form element is selected
sendKeys(str): Promise<void>
- str
- string | Array<string>
todo: uploading files ala wd.Element.sendKeys
Type a string of characters into an input
submit(): Promise<void>
Submit a form element