Files
2026-11-04 12:36:10 +08:00

930 B

English · Dansk · Bahasa Malaysia

Step 2 - Class

Because the bot has several steps, the code is organised in a class, InstaFollower. __init__ creates the Selenium driver. The three methods login(), find_followers() and follow() are called in that order.

Outline of the InstaFollower class

The class is the Selenium adapter in the infrastructure layer. A small use case, run_bot, calls the three methods through a Follower protocol, so the order is tested without a browser.

What we gained

  • Grouping steps that share state (the driver) in a class.
  • Injecting the driver and the sleep function, so tests use a fake driver and never wait.
  • Closing the browser with a context manager (with InstaFollower() as follower:).