Implementation:Getgauge Taiko ListItemWrapper
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Browser_Automation, Element_Selection |
| Last Updated | 2026-02-12 03:00 GMT |
Overview
Concrete tool for selecting HTML list item (`
Description
`ListItemWrapper` is a specialized subclass of `ElementWrapper` that locates HTML `- If attribute-value pairs are provided, it constructs a CSS query for `
- ` tags with those attributes.
- If a label string is provided, it uses the `match()` function from `elementSearch` to find `
- ` elements whose text content matches the label.
- If neither is provided (bare selector or proximity-only), it matches all `
- ` elements and relies on relative search arguments for filtering.
Usage
Use `ListItemWrapper` (via the `listItem()` selector in Taiko) when you need to interact with list items on a page. This is the appropriate selector for any `- `) or unordered (`
- Repository: Getgauge_Taiko
- File: lib/elementWrapper/listItemWrapper.js
- Lines: 1-21
- ` elements are candidates.
- ` elements. Delegates to the first match for actions like `click()`, `exists()`, and `text()`.
- `) lists, whether you are clicking on a list entry, verifying its existence, or reading its text content.
Code Reference
Source Location
Signature
class ListItemWrapper extends ElementWrapper {
constructor(attrValuePairs, _options, ...args) {
super('ListItem', 'label', attrValuePairs, _options, ...args);
this._get = getElementGetter(
this.selector,
async () => await match(this.selector.label, this._options).elements('li', 0, 0),
'li',
);
}
}
Import
const { listItem } = require('taiko');
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| attrValuePairs | string / Object / RegExp | No | A label string to match against the list item's visible text, an attribute-value pair object for CSS attribute matching, or a regular expression. When omitted, all ` |
| _options | Object | No | Options object passed through to the parent `ElementWrapper`. |
| ...args | RelativeSearchElement[] | No | Zero or more relative search elements (e.g., `near()`, `below()`) used for proximity-based filtering of results. |
Outputs
| Name | Type | Description |
|---|---|---|
| ListItemWrapper | ListItemWrapper | An `ElementWrapper` instance representing all matched ` |
Usage Examples
Basic Usage
const { openBrowser, goto, listItem, click, closeBrowser } = require('taiko');
(async () => {
await openBrowser();
await goto('https://example.com');
await click(listItem('Settings'));
await closeBrowser();
})();
Check List Item Existence
const { openBrowser, goto, listItem, closeBrowser } = require('taiko');
(async () => {
await openBrowser();
await goto('https://example.com');
const hasItem = await listItem('Dashboard').exists();
console.log('Dashboard list item exists:', hasItem);
await closeBrowser();
})();
With Attribute-Value Pairs
const { openBrowser, goto, listItem, click, closeBrowser } = require('taiko');
(async () => {
await openBrowser();
await goto('https://example.com');
await click(listItem({ class: 'active' }));
await closeBrowser();
})();
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment