Is it possible to add optional parameter in page.$ to wait for selector first, than perform searching, another words replacing
await page.waitForSelector('selector'); await page.$('selector');
with
await page.$('selector',{waitFor: true});
or something like it, because for my tests $ or $$ functions sometimes return undefined