Attach Selenium Python Test Steps Against An Existing Browser
Develop/debug Selenium Python tests efficiently.
Debugging automated test scripts, in my opinion, demands simplicity and much higher efficiency than code.
Many test automation attempts (as a result, Agile or DevOps) failed because software (test) engineers were unable to keep automated tests along with development.
Assume you have a test script with 100 test steps and a successful execution takes 100 seconds, i.e. average of 1 second per test step. Let’s say on the first run, Step 42 failed. You found the issue in the step and fixed it; You run the test again, Oops, 72 seconds later, Step 72 failed this time. As you can see, it is very time-consuming (and frustrating), as every run starts from Step 1.
Moreover, during the test development phase, for a new test step, a tester might need to experiment with different locators (to find an optimal one for accuracy, execution reliability, and efficiency). It would be a huge time-wasting if every test run restarts from the very beginning.
During my consulting, every test automation engineer I met took it (restart from Step 1 on every test run) for granted. Then I showed them a simple and much better way in TestWise: attaching executions of the selected test steps to the last browser window. The technique I have been using for over 12 years for helping clients and my own projects. I use it many times every single working day, for test scripts in Selenium Ruby.
TestWise 6 added limited support for scripting languages in Python and JavaScript. I just added this technique as a recipe in my book: Selenium WebDriver Recipes in Python. Here is a video demonstration with TestWise on macOS.
Let’s break this down into 4 simple steps
1. Run a single test case, and leave the browser open.
2. Select the test steps, right-click and select “Run Selected Scripts Against Current Browser”
3. These two steps will be executed against the current browser window, in a new test script file: debugging_test.py
4. Edit this special test in debugging_test.py, and run it as many times as you need.
Please note, this is a generic technique, TestWise is just one implementation of it (for some unknown reason, this does not work on Python tests on Windows, fine on macOS and Linux. I guess it will be a framework issue, the Selenium Python has not been updated for 1.5 years).
Explore your tool to have this feature implemented, it can easily save you hours every day.