# $$

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](https://webdriver.io/docs/api/globals) for more information. Using WebdriverIO within a [standalone](https://webdriver.io/docs/setuptypes#standalone-mode) 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'))
}
```

### Iterating over elements[​](#iterating-over-elements "Direct link to Iterating over elements")

The result of `$$` also provides asynchronous versions of the `Array` iteration methods `forEach`, `map`, `find`, `findIndex`, `some`, `every`, `filter` and `reduce`. They accept `async` callbacks and can be called on `$$` directly:

```
const texts = await $$('h3').map((h3) => h3.getText())
```

Every method except `reduce` also has a `*Series` variant (`forEachSeries`, `mapSeries`, and so on). The base method runs all callbacks **concurrently**, while the `*Series` variant runs **one callback at a time**, in list order. `reduce` always runs one callback at a time. Use a `*Series` variant when the order of your interactions with the page matters.

The concurrent `find` and `findIndex` resolve with the first match to finish, which is not necessarily the earliest match in the list, and the concurrent `find`, `findIndex`, `some` and `every` keep running the remaining callbacks after the result is known. Use the `*Series` variant to get the earliest match and stop there.

info

For more information on how to select specific elements, check out the [Selectors](/docs/selectors.md) guide.

## Usage[​](#usage "Direct link to Usage")

```
await browser.$$(selector)
```

## Parameters[​](#parameters "Direct link to Parameters")

| Name       | Type               | Details                                            |
| ---------- | ------------------ | -------------------------------------------------- |
| `selector` | `String, Function` | selector or JS Function to fetch multiple elements |

## Examples[​](#examples "Direct link to Examples")

example.html

```
loading...
```

[View on GitHub](https://github.com/webdriverio/example-recipes/blob/59c122c809d44d343c231bde2af7e8456c8f086c/queryElements/example.html)

multipleElements.js

```
loading...
```

[View on GitHub](https://github.com/webdriverio/example-recipes/blob/59c122c809d44d343c231bde2af7e8456c8f086c/queryElements/multipleElements.js#L6-L7)

multipleElements.js

```
loading...
```

[View on GitHub](https://github.com/webdriverio/example-recipes/blob/59c122c809d44d343c231bde2af7e8456c8f086c/queryElements/multipleElements.js#L15-L24)

multipleElements.js

```
loading...
```

[View on GitHub](https://github.com/webdriverio/example-recipes/blob/59c122c809d44d343c231bde2af7e8456c8f086c/queryElements/multipleElements.js#L32-L39)

## Returns[​](#returns "Direct link to Returns")

* **\<WebdriverIO.ElementArray>**
