codefights.comからページを読み込み、特定のhtml要素が読み込まれるまで待っているときに "未処理の約束を却下"しています。ここでNightmare.jsで未処理の約束を拒否
は私のコードです:ここでは
import * as Nightmare from 'nightmare';
const nightmare = Nightmare({ show: true });
nightmare
.goto('https://codefights.com/interview/EDaACHNYHyH6qQFAL')
.wait('body > div:nth-child(9) > div > div.page--header > div > span')
.evaluate((selector) => {
return document.querySelector(selector);
}, 'body > div:nth-child(9) > div > div.page--header > div > span')
.end()
.then((functionTitle) => {
console.log(functionTitle);
});
は例外です:
Unhandled promise rejection (rejection id: 1): Error: Evaluation timed out after 30000msec. Are you calling done() or resolving your promises?
この問題を解決する方法上の任意のアイデアは?拒絶反応を処理するには
あなたは未処理であることからoccuringからのタイムアウトや拒絶反応を防ぐためにしようとしていますか? – Bergi
@Bergi私は、拒否が未処理であることを防止しようとしています。私もそれを理解したと思います。評価関数は 'then'の後に約束を返さなければなりません。 – Kiril
そして、 '.catch(ハンドラー)'をチェーンに連結するか、ハンドラーを最後の 'チェーン'の第2引数として渡します。 – Bergi