Nightmare conditional wait()
问题 I'm trying to crawl a webpage using Nightmare, but want to wait for #someelem to be present, only if it actually exists. Otherwise, I want Nightmare to move on. How can this be done using .wait() ? I can't use .wait(ms) . Using .wait(selector) means Nightmare will keep waiting until the element is present, but if the page will never have this element, Nightmare will keep waiting forever. The last option is to use .wait(fn) . And I've tried something like this .wait(function(cheerio) { var $ =