.isPresent() Suggest edits
Since: 3.7.1Checks if an element is present in the DOM.
This command is useful for verifying the presence of elements that may/may not be visible or interactable.
For more info on working with DOM elements in Nightwatch, refer to the Finding & interacting with DOM Elements guide page.
For more info on the new browser.element.find()
syntax, refer to the new Element API Overview page.
Usage
browser.element.find(selector).isPresent()
Example
describe('isPresent Demo', function() {
it('test isPresent', function(browser) {
browser.element.find('#search')
.isPresent()
.assert.equals(true);
});
it('test async isPresent', async function(browser) {
const result = await browser.element.find('#search').isPresent();
browser.assert.equal(result, true);
});
});
Returns
Type | description |
---|---|
ScopedValue<boolean> | A boolean value indicating if the element is present in the DOM. |