I have been making simple code lately. however It's doesn't work. why do that? I don't understand. I guess it didn't have error syntax.
but It occurred "Cannot read property 'blur' of null"
could you please help me?
var Nightmare = require('nightmare');
nightmare = Nightmare({show: true});
nightmare.goto('https://www.google.com')
.type('form[action*="/search"] [name=f]', 'aa')
.click('form[action*="/search"] [type=submit]')
.then(function (res) {
console.log(res);
})
.catch(function (err) {
console.log(err);
});
There is a known issue where DOM elements that are changed or removed during typing events can cause a similar problem. It will be fixed in the next release of Nightmare. See #820 for details. Quoting from the fix PR:
If the element being typed or inserted into is removed from the DOM before the blur call is made (which can happen if the element is removed on a key event), an exception is raised.
blurSelector
now makes sure the element still exists before making the blur call. Also added a debug message if the selector does not exist after focusing.
Your script also appears to not be valid on the current incarnation of Google - have you also double-checked your selectors?