Iam using nodriver (https://ultrafunkamsterdam.github.io/nodriver/) and its really nice so far! 🙂
But I have a conceptual question:
How can I search for elements that I often expect not to find?
If Iam parsing a page and the page has different “states” and I want to find out, in which “state” it is and I have one object for each “state” to differentiate the them: What do I use?
So far, I often use
await page.find("XPATH-PATTERN", timeout=timeout)
And I put it into a try-expect and if its not found (TimeOutError), I progress in the except-block.
But that doesnt feel “right”… I mean, I expect the element to often not being there, its not really an Error. And if the page is laggy, I get the same Error = a wrong “state”.
I used the documentation and couldnt find any helpful method. It would help to get the readyState of the page, but couldnt find anything to do that either.
How should I handle this?