![]() The script terminates with an error, possibly of the "Element not found" sort.Ģ) The element can load before our hard wait has expired. In this case, our hard wait terminates and our click action is attempted too early. In such a situation, the following can happen:ġ) We can end up waiting for a shorter amount of time than the element takes to load! This could looks something like the following:Įnter fullscreen mode Exit fullscreen mode We try to solve this issue with a hard wait, like Puppeteer's page.waitFor(timeout). Imagine the following situation: our script is running using a tool without any sort of built-in smart waiting, and we need to wait until an element appears on a page and then attempt to click it. Let's explore these issues in practical terms through an example. This makes them dangerous: they are intuitive enough to be favoured by beginners and inflexible enough to create serious issues. Hard waits do one thing and one thing only: wait for the specified amount of time. Let's explore how those issues arise and what better solutions we can use to avoid them. This is regarded as an anti-pattern, as it lowers performance and increases the chances of a script breaking (possibly intermittently). Looking to solve the issue of a page or element not being loaded, many take the shortcut of waiting for a fixed amount of time - adding a hard wait, in other words.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |