the function do_something is not very clear:
- it interacts with with elements on the
driver's page, clicks it /send_keys to it, and then returns the attributes of the first child that was not interacted with yet.
- it relies on a global variable
already_clicked_elems.
- it doesn't have a docstring or a meaningful name.
i think that, before creating a test for that method, we should first refactor it. a few options:
- refactor
crawler.py into a Crawler class, and keep the already_clicked_elems as a member;
- refactor just
do_something by making it yield a child's attributes, that way a set is no longer needed;
- leave the global variable there for now and just focus on documentation.
either way, i think the function should be:
- renamed to something like
interact_with_clickable_chlid,
- given proper documentation + docstring,
- given type hints.
let me know what you think 🧇
the function
do_somethingis not very clear:driver's page,clicks it /send_keysto it, and then returns the attributes of the firstchildthat was not interacted with yet.already_clicked_elems.i think that, before creating a test for that method, we should first refactor it. a few options:
crawler.pyinto aCrawlerclass, and keep thealready_clicked_elemsas a member;do_somethingby making ityielda child's attributes, that way asetis no longer needed;either way, i think the function should be:
interact_with_clickable_chlid,let me know what you think 🧇