Best Practice: Use Breakpoints to Diagnose Flaky Tests on Sauce Labs

Userlevel 1
Badge +1

A "flaky" test is one that normally runs without any issues, but every so often, maybe one in a hundred times, fails for seemingly random reasons. Debugging the issue with flaky tests is challenging, but by using breakpoints in flaky tests, you can identify the specific conditions that led to the flake, and dig into the problem more deeply using your developer tools. There are two ways to use breakpoints with your Sauce Labs test: through the sauce: break Selenium command, and by using the Pause button on the Test Details page while the test is running. 

sauce: break

sauce: break is a JavaScript statement that you can insert into your Selenium execute_script command to both identify and interrupt flaky tests for further diagnosis. You can find more information in the topics Annotating Tests with Selenium's JavaScript Executor and Live Testing on Virtual Mobile Devices.

The Pause Button

When your test is running, you can use the Pause button on the Test Details page to interrupt the test and assume manual control of the browser. When you're done investigating, click Stop, and the test that you breakpointed will be marked as such on the Test Details page. 

0 replies

Be the first to reply!