Get the element on the page that currently has focus. The element will be returned as a Web Element JSON object.

The command elementActive() will automatically wait for the element to be present (until the specified timeout). If the element is not found, an error is thrown which will cause the test to fail. You can suppress element not found errors by specifying the selector argument as an object and passing the suppressNotFoundErrors = true option.

For more info on working with DOM elements in Nightwatch, refer to the Finding & interacting with DOM Elements guide page.

Please note that this command operates on a protocol level and accepts the Web Element ID as the parameter. To retrieve it, use either the .findElement() or .findElements() command. Read more on Element retrieval.



module.exports = {
 'demo Test' : function(browser) {
    browser.elementActive(function(result) {


Name Type description
callback function

Callback function which is called with the result value.

W3C WebDriver spec