无法读取 属性 'blur' of null at nightmarejs

Cannot read property 'blur' of null at nightmarejs

最近一直在做简单的代码。然而这是行不通的。 为什么要这样做?我不明白。我猜它没有语法错误。

但是它发生了"Cannot read property 'blur' of null"

你能帮帮我吗?

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);
});

存在一个已知问题,其中 DOM 元素在键入事件期间被更改或删除可能会导致类似的问题。它将在 Nightmare 的下一个版本中修复。有关详细信息,请参阅 #820。引用修复 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.

您的脚本在 Google 的当前版本上似乎也无效 - 您是否也仔细检查了您的选择器?