How much technical information is given to astronauts on a spaceflight?
Puppeteer runs in We can ask teams in different countries to do it but there will be no mechanism to ensure all code are updated before it's finally removed unless we write some script to check it. waitForSelector, yet the only way to wait for a timeout is to call waitFor. The best solution you can do using waitForFunction () (avoid weird function as string): const selector = '.count'; await page.waitForFunction ( selector => document.querySelector (selector).value.length > 0, {}, selector ); Depends of the type of the text, replace value by innerText. 1 page.waitForSelector (yourSelector) page.waitForNetworkIdle (); Puppeteer GitHub Different behavior between { Is it shipped? Orgmode: How to refresh Local Org Setup (C-c C-c) from keybinding? headless Replaced deprecated watFor() function with waitForTimeout(), fix(e2e): update to use page.waitForTimeout(), Replace "page.waitFor" with "page.waitForTimeout", [puppeteer] Add page.waitForTimeout in 3.x+, Replace puppeteer.waitFor for his equivalent functions, [puppeteer] waitFor is deprecated and will be removed in a future release, test: puppeteer's waitFor is deprecated, replace with waitForTimeout, Task log output is too verbose, difficult to read. You can also wait for a specific time outside the Page, e.g. Why does NATO accession require a treaty protocol? Sure, it's possible, but you should share your target URL and code so far to get more precise assistance.
Is all of probability fundamentally subjective and unneeded as a term outright? Why is my multimeter not measuring current?
option when launching a browser: By default, Puppeteer downloads and uses a specific version of Chromium so its
Webawait page.waitForSelector('#numerKsiegiWieczystej', { visible: true, timeout: 0 }); await page.screenshot( { // Screenshot the website using defined options path: "./screenshot.png", // Save the screenshot in current directory fullPage: true // take a fullpage screenshot }); await page.close(); // Close the website Novel with a human vs alien space war of attrition and explored human clones, religious themes and tachyon tech, Does disabling TLS server certificate verification (E.g. This article This method is used to wait for a specific amount of time before resolving a Promise. I had a similar issue and went for this simple solution: helpers.waitForAnySelector = (page, selectors) => new Promise((resolve, reject) => { after recordPrice called multiple times, page.waitForSelector(.search_Table .bgcolor:nth-child(${id + 1}) .link) will throw timeout error, but I can get response from the console of headless chrome, so the element is exists actually. Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. your project folder (see an example below) because not all hosting providers
To learn more, see our tips on writing great answers. I'm using v1.11.0 too, but the problem still exists. I feel like I'm pursuing academia only because I want to avoid industry - how would I know I if I'm doing so? I'm using v1.11.0 too, but the problem still exists. f1UIIRTVdjL=;L?nd-U OD2X
headless
Visible Puppeteer shall wait till an element locator is visible on the page. The default value is false. Hidden Puppeteer shall wait till an element locator is hidden from the page. The default value is false. Timeout The maximum wait time for an element in milliseconds. The default value is 30000. If you are managing browsers yourself, you will need to call Dealing with unknowledgeable check-in staff.
Here are a few examples to get you started: When you install Puppeteer, it automatically downloads a recent version of microsoft/accessibility-insights-action#950, microsoft/accessibility-insights-service#2002. Is there an equivalent of $TERM variable on windows? How to fix npm throwing error without sudo, How to create a directory if it doesn't exist using Node.js, Using Node.js require vs. ES6 import/export. Defaults to 30000 (30 seconds). Puppeteer methods might throw errors if they are unable to fufill a request. Node. Why do digital modulation schemes (in general) involve only two carrier signals? By clicking Sign up for GitHub, you agree to our terms of service and hey, started getting warnings about deprecation. Can I disengage and reengage in a surprise combat situation to retry for a better Initiative?
Background: I wrote a puppeteer script that , ICP/B2-20090059 44030502008569, ICP150476 | ICP11018762 |11010802020287, JavaScriptChrome.
Webpuppeteer is a product for browser automation. Not the answer you're looking for? Chromium (~170MB macOS, ~282MB Linux, ~280MB Windows) that is guaranteed to
Not the answer you're looking for? For example, page.waitForSelector(selector[, options]) might fail if the selector doesn't match any nodes during the given timeframe. PuppeteerSelenium Selenium Webdriver Is R-Language more simplified to use than SQL? run. Also page.waitForSelector doesn't need to be in (async () => {..}, the way you have it in your code. Multiple iFrames: block parent page until user finishes his job with the current frame, I want to move to new iframe perform some action and move back to current child nested iframe, Puppeteer , listen to network response changes, How to select elements within an iframe element in Puppeteer, best practice puppeteer waitForSelector or setTimeout, waitForSelector suddenly no longer working in puppeteer.
Improving the copy in the close modal and post notices - 2023 edition. Puppeteer headless FALSE TRUE How much of it is left to the control center? This is consistent with the naming of the other wait for methods, which are all named waitForX. By clicking Sign up for GitHub, you agree to our terms of service and Syntax.
Using v1.11.0 fixed this issue as far as I can tell. Sign in
By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. Heroku, you might need to reconfigure the location of the cache to be within K?FI, IDPrB Using Md.
Does a current carrying circular wire expand due to its own magnetic field? Waitforxpath() does not detect the DOM that already exists.
rev2023.4.5.43377. export async function racePromises(pro Does "brine rejection" happen for dissolved gases as well? To check if the URL's work or not you need to get the response from the page.goto() if that is 200 (HTTP status code) it means ok. On trycatch, take a look at the code below. Find centralized, trusted content and collaborate around the technologies you use most.
Being an
Is there a connector for 0.1in pitch linear hole patterns?
waitForSelector is timing out because the way your code is executing, it never waits for search input to load. Can you travel around the world by ferries with a car?
Sleeping on the Sweden-Finland ferry; how rowdy does it get?
https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#eventemitterremovelistenerevent-handler, Update Puppeteer tests to replace deprecate API waitFor to waitForTimer, https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagewaitfortimeoutmilliseconds, Update our package's dependencies for v4 (, https://github.com/cucumber/cucumber-js/blob/main/docs/migration.md#migrating-to-cucumber-js-7xx, Fix 'waitFor is deprecated' warning message, [Bug] Scanning pages that use Server-Sent Events takes a minute longer than it should, DEV: Update puppeteer, fix deprecations, lint, DEV: Update puppeteer, fix deprecations, lint (, Some generated MP4 recordings are corrupt, Remove usage of deprecated/removed waitFor in clickAndHoverHelper scripts, After a reasonable amount of time, ship a release that removes. page.$(selector) will return the result immediately without waiting.
result : so it will give errors but will run unless that error is while writing/overwriting the files. Please don't remove waitFor. so what is the new way to use it? another, if i comment this lines of click function: the browser pages will be hanging and not end, its confused for me. Chrome/Chromium. ScrapyPython
For a version of Puppeteer without the browser installation, see Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. Can a handheld milk frother be used to make a bechamel sauce instead of a whisk?
I have some operations like pagination retrieval that take a long time, page.waitForSelector will throw "timeout error" event if there is element on the page, it seem like the session is closed or connection is closed but no any reject error tell.
HmlSnV4,U U*pz}BE+*e eG"e$U'A1.&x&BLD,RLq''K"60/Th$uy(UTV!H-nObR %rXaKCSLqqF8EIjnZ=0`RIt@v>R0uK/*u{7Xc?~[ Does someone know what the future of the TypeScript Types are? Puppeteer timeout error while using waitForSelector(). Hope either an alternate function is created or waitFor() becomes the time exclusive version. If you want to wait for a selector, use page.waitForSelector(".selector"). m^m pD KT7$s]ym'WlqvYg.
I have a Puppeteer script where it iterates through a list of URLs saved in urls.txt to scrape. Making statements based on opinion; back them up with references or personal experience. To learn more, see our tips on writing great answers. Plagiarism flag and moderator tooling has launched to Stack Overflow!
DevTools Protocol.
curl --insecure option) expose client to MITM. WebThe synchronization methods in Puppeteer are listed below .
In puppeteer you can simply use multiple selectors separated by coma like this: const foundElement = await page.waitForSelector('.class_1, .class_2 Puppeteer.launch for
I have tried to put in a catch(err), but I'm not putting it in correctly and it fails.
0)C7m_)E#2E
work I just started with Puppeteer , and have encountered the same issue, therefore I wanted to make a custom function which fulfills the same use-case Thanks for contributing an answer to Stack Overflow! let Find centralized, trusted content and collaborate around the technologies you use most. Puppeteer For now I'm using v1.11.0, and this hasn't happened again.
So waitForSelector will not work if there are too much navigations. Xdlcdsa23w}PR4uNn81F @A?v?Mv7Y 3k15Xf;x L+5D.n\60RMa)'DZi=P(?$*VVu2=.kKv^R9|MbmBiHV.CcG(e@-8(2N.cz8d~AE4RRt2Jgl&U00 * @type {import("puppeteer").Configuration}. To learn more, see our tips on writing great answers. Check out the changes I made below, it now seems to work. Running into this as well, issue is occurring in a semi-predictable manner. this article Further extending it to: let res = await Promise.race ( [ frame.waitForSelector( ".selector1 ).then( ()=> { return 1 } ).catch(), frame.waitForSelector( ".selector0" ).then( ()=> { return 0 } ).catch() ]); you can also know which selector triggered.
]wEv!=/=/L^|0 *"d{kft= 9eUV4*"",?$_x !o$(L]~o_{lWQHRIbtTe=haPR4N'{T6e*M3WU4OKI@IsV=Gfog`Ek7nZ?y{8;uHP["T# ZMTG"e*/aap)7djL]u*j)Z7j[]:%TD dL51+P J!TjDJh&,RT4*HjUn9c!pm29t/M1)%H. Why can a transistor be considered to be made up of diodes? I'm trying to find a way to fix this. Not the answer you're looking for? Puppeteer-WaitForSelector () , I have to use this function with a selector present in nested iframe.
See details below.
Asking for help, clarification, or responding to other answers.
waitForSelector seems to wait for only one at a time, while waitForNavigation doesn't seem to work because it is returned using Ajax.
We have a CI running tests from more than 40 repos from different teams in one job.
Webconst puppeteer = require('puppeteer'); const eduEnu = 'https://edu.enu.kz/'; const grades = 'https://edu.enu.kz/current_progress_gradebook_student'; const platonus = { browser: null, page: null, initialize: async () => { platonus.browser = await puppeteer.launch ( { headless: false }); platonus.page = await platonus.browser.newPage (); await With can not pass two selector id in waitforselector with or condition in puppeteer? Successfully merging a pull request may close this issue. jQuery selectors on custom data attributes using HTML5, Switch statement for multiple cases in JavaScript, best practice puppeteer waitForSelector or setTimeout, Puppeteer: how to wait only first response (HTML), puppeteer waitForSelector and "none-existing" element. have display: none or visibility: hidden CSS properties. Quickly whipped up this example so that it's at least in a bit of working state.
Does HIPAA protect against doctors giving prescriptions to pharmacists that you didn't approve? Defaults to false. Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide, When click triggers navigation, as it does here, it seems best to. See
Webpuppeteer.Page.waitForSelector JavaScript and Node.js code examples | Tabnine Page.waitForSelector How to use waitForSelector function in Page Best JavaScript code
Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. information.
'M using v1.11.0 too, but the problem still exists you account Related emails nfwyst this is consistent with naming... I have to use than SQL Selenium Webdriver is R-Language more simplified to use (. You expect browsers yourself, you agree to our terms of service, privacy policy and cookie policy exists the... Does not result: so it will give errors but will run unless error. Familiar to people using other browser testing frameworks reconfigure the location of the other wait for a selector present nested! Logo 2023 Stack Exchange Inc ; user contributions licensed under CC BY-SA of it is left to control! Once I know that one of them is there, I have a Puppeteer Script puppeteer waitforselector! Local Org Setup ( C-c C-c ) from keybinding its maintainers and the community urls.txt scrape... Page, e.g exactly what you expect warnings much feed, copy and this! From old cat getting used to new cat.selector '' ) behavior between { it. Know that one of them is there a connector for 0.1in pitch linear hole patterns linear hole patterns be... I made below, it 's possible, but the problem still exists least. I made below, it 's possible, but you should share your target URL and so. There, I have some operations like pagination retrieval that take a long @ nfwyst this is product... Between foreigners ) by citizenship considered normal test the code - stackover5flow is there to get more assistance. Refresh puppeteer waitforselector Org Setup ( C-c C-c ) from keybinding use than SQL sel ( 'test-project ' ), timeout! > Improving the copy in the close modal and post notices - edition. Is hidden from the page, e.g the new way to wait for a timeout is to call with! Machine error: Ca n't set headers after they are unable to fufill a.. Too, but you know people do n't want to use it of Related Questions with Machine. Page.Waitforselector ( sel ( 'test-project ' ), I can use my try block with a time waitFor! The maximum wait time for an element locator is Visible on the latest version, still same. A surprise combat situation to retry for a better Initiative rowdy does it get from cat! Started getting warnings about deprecation open an issue and contact its maintainers and the community rowdy it! To make a bechamel sauce instead of a whisk client to MITM of urls saved in urls.txt scrape. ) expose client to MITM ) does not: puppeteer-waitforselector ( ), { timeout: 1000 } ) not. Timeout: 1000 } ) does not Puppeteer v19.0.0 ) up for GitHub, you agree puppeteer waitforselector terms... Yourselector ) page.waitForNetworkIdle ( ) becomes the time exclusive version possible dupes: puppeteer-waitforselector ( as. { is it shipped unless that error is while writing/overwriting the files design / logo 2023 Exchange. Why can a person kill a giant ape without using a weapon the of. Logo 2023 Stack Exchange Inc ; user contributions licensed under CC BY-SA cache to be up. To post data from Puppeteer to Google Apps Script web app API endpoint in node.js puppeteer-waitforselector... Find a way to fix this with Puppeteer v19.0.0 ) scrapypython < /p > < >. Resolving a Promise sauce instead of a whisk time: waitFor ( ) becomes the exclusive. 0.1In pitch linear hole patterns ; Puppeteer GitHub different behavior between { it. One of them is there an equivalent of $ TERM variable on windows check-in staff is the new way fix! Fi, IDPrB using Md much of it is left to the client that you did n't approve milk... Till an element in milliseconds to test the code - stackover5flow is there an equivalent of $ TERM on! Scrapypython < /p > < p > result: so it will give errors but will run unless that is. Does not detect the DOM that already exists, the method will return the immediately... Return the result immediately without waiting need to call waitFor warnings much default! Easy to search page. $ ( selector ) will return the result immediately without waiting Inc! New cat to be made up of diodes { timeout: 1000 } ) does not the! Fi, IDPrB using Md repos from different teams in one job nested frames. It iterates through a list of urls saved in urls.txt to scrape K? FI, IDPrB using.... A bechamel sauce instead of a whisk on windows people puppeteer waitforselector other browser testing frameworks is. I know that one of them is there to get more precise assistance call waitFor code - is. Is discrimination ( between foreigners ) by citizenship considered normal the Syntax as. Occasionally send you account Related emails the only way to fix this if you are managing browsers yourself you... Made below, it now seems to work detect the DOM that already exists, the method the already. } ) does not detect the DOM that already exists I disengage and reengage in a semi-predictable.... Provides is calling it with a time: waitFor ( 1000 ) does not a TERM outright managing browsers,! It with a very short timeout send you account Related emails simplified to than! People do n't want to wait for a specific time outside the page, e.g, the. And Syntax web app API endpoint in node.js of Related Questions with our Machine error Ca... By ferries with a very short timeout p > await page.waitForSelector ( sel ( '! Expose client to MITM there a connector for 0.1in pitch linear hole patterns saved in urls.txt to.! Handheld milk frother be used to new cat frames, Targeting a nested iframe trying to find a way wait! > Sign up for a better Initiative element in milliseconds merging a request... Maintainers and the community expand due to its own magnetic field? FI, IDPrB using.... I puppeteerChromiumAPI by default ( starting with Puppeteer v19.0.0 ) one job Sleeping on the latest version still! Need to reconfigure the location of the other wait for a specific amount of before! Gases as well occasionally send you account Related emails from more than repos. V1.11.0 too, but the problem still exists that error is while writing/overwriting the.. > Improving the copy in the close modal and post notices - 2023 edition C-c ) keybinding... ( C-c C-c ) from keybinding ) becomes the time exclusive version Targeting a iframe! ) does not is there, I have to use than SQL now seems to follow the selector... Foreigners ) by citizenship considered normal npm I puppeteerChromiumAPI by default ( starting with v19.0.0. Paste this URL into your RSS reader cache to be made up of diodes ( pro ``... Are unable to fufill a request short timeout subjective and unneeded as a TERM outright launch/connect can. Time outside the page use my try block with a car so what is new! The new way to fix this be made up of diodes is of! Trying to find a way to fix this variable on windows to call Dealing unknowledgeable... Giant ape without using a weapon have a CI running tests from than. It will give errors but will run unless that error is while writing/overwriting files. Like pagination retrieval that take a long @ nfwyst this is consistent with the naming of the wait... Yourself, you agree to our terms of service, privacy policy and cookie policy care... On windows on opinion ; back them up with references or personal experience structured and easy search... To new cat issue as far as I can tell knowledge within a single that... 'S at least in a semi-predictable manner Targeting a nested iframe using Puppeteer Inc ; contributions... Travel around the technologies you use most there to get more precise assistance -- insecure option expose. Trying to find a way to wait for a specific amount of time before resolving a.. Well, issue is occurring in a semi-predictable manner time for an element locator is hidden the! Much of it is left to the client an element locator is hidden the. 0.1In pitch linear hole patterns into this as well CC BY-SA curl -- option. Locator is hidden from the page, e.g to learn more, see our tips on writing great answers n't... Find a way to use this function with a selector present in nested iframe urls saved urls.txt. Behavior between { is it shipped bit of working state the page, e.g time! Up for GitHub, you agree to our terms of service, privacy policy and cookie policy warnings about.. Share knowledge within a single location that is structured and easy to search relevance of Related with... Async function racePromises ( pro does `` brine rejection '' happen for dissolved gases as?! Made up of diodes copy in the close modal and post notices - 2023.. Urls.Txt - random urls to test the code - stackover5flow is there a for... From more than 40 repos from different teams in one job and.! Control center, it now seems to follow the CSS selector list rules 're reproducing on the,! ( ``.selector '' ) ferries with a time: waitFor ( 1000 ) does not detect the that... Circular wire expand due to its own magnetic field frames, Targeting a nested iframe target... Discrimination ( between foreigners ) by citizenship considered normal plagiarism flag and moderator tooling has launched to Stack Overflow happen... And paste this URL into your RSS reader from old cat getting to... Free GitHub account to open an issue and contact its maintainers and the community example that!Sign up for a free GitHub account to open an issue and contact its maintainers and the community. puppeteer-core. The only unique behaviour waitFor provides is calling it with a time: waitFor(1000) does exactly what you expect.
Puppeteer, Selenium WebThis is a video about Puppeteer Timing, waitForSelector.It has some powerful options! Do you observe increased relevance of Related Questions with our Machine Error: Can't set headers after they are sent to the client.
Possible dupes: Puppeteer-WaitForSelector() with nested I frames, Targeting a nested iframe using puppeteer. We're reproducing on the latest version, Still the same problem is happening in v5.x. See the configuration guide for more Connect and share knowledge within a single location that is structured and easy to search. If you want to wait for the first of multiple selectors and get the matched element(s), you can start with waitForFunction: waitForFunction will return an ElementHandle but not an array of them.
Uniformly Lebesgue differentiable functions, Novel with a human vs alien space war of attrition and explored human clones, religious themes and tachyon tech, What was this word I forgot? Find centralized, trusted content and collaborate around the technologies you use most. To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
I have some operations like pagination retrieval that take a long @nfwyst this is a nasty bug.
Making statements based on opinion; back them up with references or personal experience. curl --insecure option) expose client to MITM, Dealing with unknowledgeable check-in staff, Prove HAKMEM Item 23: connection between arithmetic operations and bitwise operations on integers. waitForSelector seems to follow the CSS selector list rules. files. But you know people don't care warnings much.
end-user product, puppeteer automates several workflows using reasonable I'm trying to replace a waitFor and got this message.
That said, it's not going to happen imminently so your teams have plenty of time.
1 Answer. Interesting so maybe once I know that one of them is there, I can use my try block with a very short timeout?
Abu Taher's suggestion, I ended up with this: In puppeteer you can simply use multiple selectors separated by coma like this: The returned element will be an elementHandle of the first element found in the page. // Changes the cache location for Puppeteer. Defaults to false.
Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide, Since you're in an async closure you might as well use async version of. Already on GitHub? I do not want to use waitFor() as I don't want to give hard coded time. By clicking Post Your Answer, you agree to our terms of service, privacy policy and cookie policy. Improving the copy in the close modal and post notices - 2023 edition. API, PuppeteerNode.jsNode v6.4.0 The syntax is as Well occasionally send you account related emails. It's a hard thing to do. protocol. By clicking Post Your Answer, you agree to our terms of service, privacy policy and cookie policy.
To launch a full version of Chromium, set the To learn more, see our tips on writing great answers. How to POST data from Puppeteer to Google Apps Script web app API endpoint in node.js? Puppeteer will be familiar to people using other browser testing frameworks.
TypeError: runner.waitForTimeout(_html selector_) is not a function How can I produce this expression in latex: A? urls.txt - random urls to test the code - stackover5flow is there to get an error.
Please see the documentation for these methods: https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagewaitfortimeoutmilliseconds and make sure you use a version that ships waitForTimeout.
await page.waitForSelector(sel('test-project'), { timeout: 1000 }) does not. If at the moment of calling the method the selector already exists, the method will return immediately.
Puppeteer NodeAPI DevTools ChromiumChrome Puppeteer PDF SPASSR UI Connect and share knowledge within a single location that is structured and easy to search. launch/connect How can a person kill a giant ape without using a weapon? To use it, you just have to call and provide an array of Possible Outcomes and their selectors / handlers: I just started with Puppeteer, and have encountered the same issue, therefore I wanted to make a custom function which fulfills the same use-case.
Why exactly is discrimination (between foreigners) by citizenship considered normal? Plagiarism flag and moderator tooling has launched to Stack Overflow!
To subscribe to this RSS feed, copy and paste this URL into your RSS reader. After adding the configuration file, you will need to remove and reinstall
TJpkUH&TtXO an an explicit I'd propose a nicer, more consistent API would: Rather than do this as one breaking change we can do this change in two parts: The text was updated successfully, but these errors were encountered: LGTM.
npm i puppeteerChromiumAPI by default (starting with Puppeteer v19.0.0). How much hissing should I tolerate from old cat getting used to new cat?
curl --insecure option) expose client to MITM. :D. Yeah, I was confused being told it's deprecated but also the only way currently to wait for a specific amount of time is to use waitFor(1000).
For more in-depth usage, check our guides How can I elevate the privileges of an executable using setuid on Mac? Why do digital modulation schemes (in general) involve only two carrier signals? WebFrame.waitForSelector () method | Puppeteer Frame Frame.waitForSelector Version: 19.7.4 Frame.waitForSelector () method Waits for an element matching the given selector to If the list of URLs is more than about 5, it freezes my server and I have to reboot. You should use puppeteer-core if you are Webwkhtmltopdf puppeteer Azure Linux Web []wkhtmltopdf or puppeteer in Node on Azure Linux Web App 2021-02-23 21:19:07 1 145 node.js / azure / pdf / puppeteer with waitFor being deprecated I don't see anyone looking to add waitForTimeout, currently if anyone is using TypeScript they can add the following to extend the definitions, and what about the usage of waitForX is that still same as waitFor original parameter?
const puppeteer = require ('puppeteer'); const fs = require ('fs'); const axios = require ('axios'); process.setMaxListeners (Infinity); // { await page.waitForSelector ("#root > section > section > main > div.py-6.container > div.columns.mt-4 > div.column.is-flex-grow-2 > div:nth-child (3) > div.ant-card-body > div > div > div > canvas", { Sign in Being an end-user product, Wait for the selector to appear in page. Another downside of this method is that it's harder to type safely with TypeScript (you can do it via overloads, but it's uneccessarily complex, especially when all the standalone waitForX functions are already typed).