$$
The $$
command is a short and handy way in order to fetch multiple elements on the page.
It returns a ChainablePromiseArray
containing a set of WebdriverIO elements.
Using the wdio testrunner this command is a global variable, see Globals
for more information. Using WebdriverIO within a standalone
script it will be located on the browser object instead (e.g. browser.$$
).
You can chain $
or $$
together without wrapping individual commands into await
in order
to walk down the DOM tree, e.g.:
const imageSrc = await $$('div')[1].nextElement().$$('img')[2].getAttribute('src')
It is also possible to use async iterators to loop over the result of the query, e.g.:
// print all image sources
for await (const img of $$('img')) {
console.log(await img.getAttribute('src'))
}
information
For more information on how to select specific elements, check out the Selectors guide.
Usage
browser.$$(selector)
Parameters
Name | Type | Details |
---|---|---|
selector | String , Function | selector or JS Function to fetch multiple elements |
Examples
example.html
loading...
multipleElements.js
loading...
multipleElements.js
loading...
multipleElements.js
loading...