One of the most frustrating things about browser automation is that, while the human brain can handle things like
wait a few minutes for the page to load and
don't click until a button is on the page, a computer isn’t always so bright.
For that reason, you need to have a strong handle on handling async interactions before you dig into browser automation. Before the WebScraping Workshop, take some time to refresh your memory on how Promises work!
Practice: Promise It Won’t Hurt Workshop
npm install -g promise-it-wont-hurt
You can run the commandline tool in your terminal by running:
Learn more, if you’re curious, in the README.
You should aim to complete, at minimum, the Warm Up & Fulfill a Promise & Reject a Promise
Feel free to get started on the exercises immediately, or, if you prefer to warm up by reading first - we recommend the following resources.
Note: If you get stuck in the workshop, the solutions are all included in the repo if you dig far enough.
Note: If NodeSchool doesn’t work on your machine, of you don’t like the commandline tool - check out this other promises workshop
Note: If you already feel solid on using promises - work on Learn Generators instead
Review the following questions and come up with some theories
- What are the states of a promise?
- What is the difference between a callback, a promise or a generator?
- Why do we have Promises when we already have Callbacks?
- Is it critical that we write Promises all the time?
- Is jQuery using promises?
Check out one take on the answers here: Promises Q&A Answers