import Nightmare from 'nightmare'; Nightmare.action('login', function(name, password, done) { this.goto('http://localhost:5000/auth/?apiKey=salix') .wait('body > vn-login > div > div > div > form > vn-textfield:nth-child(1) > div > input') .type('body > vn-login > div > div > div > form > vn-textfield:nth-child(1) > div > input', name) .type('body > vn-login > div > div > div > form > vn-textfield:nth-child(2) > div > input', password) .click('input[type="submit"]') .then(done); }); Nightmare.action('getInnerText', function(selector, done) { this.wait(selector) .evaluate_now(function(elementToSelect) { return document.querySelector(elementToSelect).innerText; }, done, selector); });