From what I understand (it's 1am here, I may miss something), you need your tests to be synchronized with AngularJS, waiting for outstanding requests and angular to "settle down".
This is what, in Javascript world, protractor
solves perfectly - it always knows when Angular is ready and it makes the tests much more natural, you don't even think about synchronization issues - it works smoothly and out of the box:
You no longer need to add waits and sleeps to your test. Protractor
can automatically execute the next step in your test the moment the
webpage finishes pending tasks, so you don’t have to worry about
waiting for your test and webpage to sync.
As for Python, there is pytractor
project that sounds like something you should evaluate:
pytractor is an extension to the Selenium bindings for Python. Its
goal is to make testing of angular.js applications easier with Python.
It is built on some parts of protractor, the "official" Javascript
E2E/Scenario testing framework for Angular.js.
As a red flag, note that the project is not actively maintained. At least, you may study the source and use the ideas introduced in the code.
Note that internally protractor
and pytractor
inject client-side scripts which are asynchronously executed. In order to wait for Angular to be "ready", they both use angular.getTestability(el).whenStable()
(source).
See also: