image

Tests fail. Sometimes it’s a bug, sometimes it’s an expected system change. You need to fix those failures!

Here’s a quick walk through of one easy way to resolve test failures using the visual debugger. (You can find additional information here in our documentation, too!)

First, open up the Quick Execution Options dialog from the main ribbon panel and select On All Errors for the auto-pause option. (You could select other options as well; I simply default to All Errors when debugging failing tests.)

image

The UI is nearly identical if you’re using Test Studio’s plugin for Visual Studio; the icon for the dialog is just in a slightly different spot. (No, the test isn’t failing in the Visual Studio version!)

image

Once you’ve set that, execute the test with Internet Explorer. When the test fails, click the Diagnose button.

image

You’ll be presented one of two dialogs next, depending on what the cause of the failure was. If a verification failed, you’ll see the Verification Sentence Builder where you can walk through fixing the verification. If the failure was due to a broken find logic then you’ll see the Find Element screen where you can work on updating the find logic.

image

You can edit the filters on this screen directly if you know exactly what’s needed to fix things. However, it’s likely you may need to reference the page’s Document Object Model (DOM) directly, so click the Select New Element button to bring up the DOM Explorer.

image

Finding the right element is a snap!

  1. Type a search term in to quickly locate your target element. (You could also scroll through the DOM as needed. You could also hit yourself in the head with a shoe. Neither are very productive, so I use Search.)
  2. Select the appropriate result from the list.
  3. Validate in the DOM window that you’ve got the right target element.
  4. Click Done to accept your new element.

You’ll find yourself back on the Find Element screen with a nice green message showing you the element’s successfully been found on the page.

image

Click Save to close out the screen.

Re-run the current step to ensure your fix works. Do that via the green button on the Visual Debugger. Note that the step works correctly!

image

When the test is finished you’ll be back at the Quick Execute window. You’ll see a new dialog asking you about applying the changes you just made. Click the Apply button and you’ll see the Testcase Selector window appear. Here you can select which test cases to apply the element changes to. I’ve selected All. (Note the Apply button greys out right after you click it to open the Testcase Selector.)

image

Keep in mind one tremendous aspect of this operation: you’re fixing every test which depended on the broken element. This all traces back to Test Studio storing locators centrally in the element repository. One easy update, every broken test fixed!

Click OK to apply the changes. You’ll get a nice little confirmation message in the dialog.

image

After this, re-run the test to validate everything’s worked fine. Naturally you’ll want to monitor any test lists impacted by these changes – you should see all previously broken tests working again!

image

There you have it, an easy way to fix your broken tests on the fly!

About the author

Jim Holmes

Jim Holmes

has around 25 years IT experience. He is co-author of "Windows Developer Power Tools" and Chief Cat Herder of the CodeMash Conference. He's a blogger and evangelist for Telerik’s Test Studio, an awesome set of tools to help teams deliver better software. Find him as @aJimHolmes on Twitter.


Related Posts

Comments

Comments are disabled in preview mode.