Skip to content
This repository was archived by the owner on Sep 3, 2020. It is now read-only.

Commit c331736

Browse files
author
Jan Krems
committed
Add API docs for getElementOrNull
1 parent fcf4c6a commit c331736

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

API.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ button = browser.getElement('.button')
138138
button.click()
139139
```
140140

141+
### browser.getElementOrNull(cssSelector)
142+
143+
Finds an element on the page
144+
using the `cssSelector`
145+
and returns an [Element](#element).
146+
Returns `null` if the element wasn't found.
147+
148+
```coffee
149+
button = browser.getElement('.button')
150+
button?.click()
151+
```
152+
141153
### browser.getElements(cssSelector)
142154

143155
Finds all elements on the page

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ Method | Description
256256
`browser.refresh()` | Refresh the current page.
257257
`browser.capabilities` | Is an object describing the [WebDriver capabilities](https://code.google.com/p/selenium/wiki/JsonWireProtocol#Capabilities_JSON_Object) that the current browser supports.
258258
`browser.getElement(cssSelector)` | Finds an element on the page using the `cssSelector` and returns an Element.
259+
`browser.getElementOrNull(cssSelector)` | Finds an element on the page using the `cssSelector`. Returns `null` if the element wasn't found.
259260
`browser.getElements(cssSelector)` | Finds all elements on the page using the `cssSelector` and returns an array of Elements.
260261
`browser.waitForElementVisible(cssSelector, timeout=3000)` | Waits for the element at `cssSelector` to exist and be visible, then returns the Element. Times out after `timeout` ms.
261262
`browser.waitForElementNotVisible(cssSelector, timeout=3000)` | Waits for the element at `cssSelector` to exist and not be visible, then returns the Element. Times out after `timeout` ms.

0 commit comments

Comments
 (0)