No video
Debugging "pytest" tests with "ipdb" debug mode
Debug Mode in "pytest" can be triggered in a few different ways:
1) Your test raises an exception after passing the "--pdb" option to pytest.
2) The moment your test begins after passing the "--trace" option to pytest.
3) Calling "pdb.set_trace()" or "ipdb.set_trace()" from your test after importing "pdb" or "ipdb" respectively. (Python versions 3.7+ and newer can also use the "breakpoint()" method to enter Debug Mode.)
(Note that you may need to add "-s" to your "pytest" run command to allow breakpoints, unless you already have a "pytest.ini" file present with "addops = --capture=no" in it.)
See seleniumbase.c... for the written tutorial.
(Example tests seen here use the SeleniumBase framework for Web-UI testing.)
Пікірлер: 8
Looks like some nice feature additions for debugging tests. Thanks.
Thank you michael, waiting for more tutorial
Holy Tabs!! Thanks for the video
awesomsauce! but is there a way in debug mode to test out different selectors? like get text from an element on the page or check if perhaps another selector would fit better while the test is paused?
@MichaelMintz
Жыл бұрын
In debug mode, all the usual commands work. Eg. Use `self.is_element_visible("SELECTOR")` to find out if a selector is visible, etc. `self.get_text("SELECTOR")` to get text from a selector, and all the other methods.
@ulfgj
Жыл бұрын
@@MichaelMintz ah! absolutely fantastic. tnx!
Thank you for the tutorial! When would you use this over breakpoints with an IDE like PyCharm?
@MichaelMintz
2 жыл бұрын
That depends when you want the breakpoint to occur. ``--pdb`` for a breakpoint on exception. ``--trace`` for a breakpoint immediately after tests start. ``ipdb.set_trace()`` for a specific location. It can be combined with IDE breakpoints. You have options.