Selenium WebElement

View as Markdown

All WebElement methods available when using the Selenium driver.

You get a RemoteWebElement from driver.findElement() or driver.findElements().

Actions

click()

Click the element.

1const el = await runtime.driver.findElement({ css: '#submit' });
2await el.click();

sendKeys(…text)

Type text into the element or send key sequences.

1await el.sendKeys('hello world');
ParameterTypeRequiredDescription
...textstring[]YesText or key sequences to send

clear()

Clear the element’s value (for input/textarea).

1await el.clear();

submit()

Submit the form containing this element.

1await el.submit();

Content

getText()

Get the visible text of the element.

1const text = await el.getText();

Returns string


getAttribute(name)

Get an attribute value.

1const href = await el.getAttribute('href');
ParameterTypeRequiredDescription
namestringYesAttribute name

Returns string | null


getCssValue(propertyName)

Get a CSS property value.

1const color = await el.getCssValue('background-color');
ParameterTypeRequiredDescription
propertyNamestringYesCSS property name

Returns string


getTagName()

Get the element’s tag name.

1const tag = await el.getTagName(); // e.g., "div"

Returns string


getRect()

Get the element’s position and dimensions.

1const rect = await el.getRect();
2// { x, y, width, height }

Returns { x: number, y: number, width: number, height: number }


State Checks

isDisplayed()

Check if the element is visible.

1const visible = await el.isDisplayed();

Returns boolean


isEnabled()

Check if the element is enabled.

1const enabled = await el.isEnabled();

Returns boolean


isSelected()

Check if the element is selected (for checkboxes, radio buttons, options).

1const selected = await el.isSelected();

Returns boolean


Screenshots

takeScreenshot()

Take a screenshot of this specific element.

1const base64 = await el.takeScreenshot();

Returns string — base64-encoded PNG.


Queries

findElement(locator)

Find a child element within this element.

1const child = await el.findElement({ css: '.child' });
ParameterTypeRequiredDescription
locatorLocatorYesElement locator

Returns RemoteWebElement


findElements(locator)

Find all matching child elements within this element.

1const children = await el.findElements({ css: '.item' });
ParameterTypeRequiredDescription
locatorLocatorYesElement locator

Returns RemoteWebElement[]