1.1 KiB
1.1 KiB
English · Dansk · Bahasa Malaysia
Step 5 - Follow
follow() finds every "Follow" button in the followers list and clicks it with a one second pause between clicks, so the bot looks less like a machine. Buttons that already say "Following" are skipped.
If a click is intercepted by the "Unfollow?" pop-up (an account that is already followed), Selenium raises ElementClickInterceptedException. The bot clicks "Cancel" and carries on with the next button.
What we gained
- Handling a specific exception on purpose: no bare
except, and only the case the assignment describes. - Testing that error path with a fake driver that raises the exception.
- Respecting the service: one second between clicks, and a mock service with a "Reset Share-a-Naan" button for clean re-runs.

