Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

Getting my customized "Pass and Move" button to work


#1

Hello,

I am trying to make a customized button (Pass and move - temp name) for test rail that will allow me to use the “Pass and Next” feature, but unlike that particular button, it will stop the timer, submit the result and time, move to the next test case and automatically start the timer. The user flow is as follows:

  1. Start a test case and start time.
  2. Obtain test case results and hit “Pass and Move”
  3. Results + Time are tracked, UI flow moves on to the next test case and time has started.
  4. Steps 2 and 3 loop until all test cases are done

So far I got it working and where I want it, but I can’t get it to log the time, or automatically start time on the next test case. Any help would be appreciated.

name: Button Test Case
description: Button to quickly move on and track time.
author: Murphy
version: 1.0
includes: ^runs/view
excludes: 

js:
$(document).ready(function() {
    'use strict';

    console.log('Script is running');
	
	var observer = new MutationObserver(function(mutations) {
		mutations.forEach(function(mutation) {
			console.log(mutation);
			if (mutation.addedNodes && mutation.addedNodes.length > 0) {
				// element added to DOM
				var hasClass = [].some.call(mutation.addedNodes, function(el) {
					return el.classList && el.classList.contains('qpane-body');
				});
				if (hasClass) {
					// element has class `MyClass`
					console.log('element ".MyClass" added');
					$('#qpane-body .button-group.form-buttons').append(' <a id="passMove" href="javascript:void(0)" class="button button-droppie-parent button-left button-pass">Pass & Move</a>');
					
					$('a#passMove').click(function()
					{
						this.blur(); App.Tests.addResultAndNext(5, App.QPane.current_id, 1, true); 
						return false;
						
					});;
				}
			}
		});
	});

	var config = {
		attributes: true,
		childList: true,
		characterData: true
	};

	observer.observe(jQuery('#qpane-content')[0], config);
});

#2

Hi Murphy,

Thanks for your posting. The internal Pass and Next JS API does not support submitting the elapsed time directly so the best option is to start & stop the timer manually. This opens the Add Result dialog the moment you stop and this involves an additional click/enter. Happy to look into this with a future version though and it would certainly make sense to automatically stop and submit the timer with Pass and Next (and the keyboard shortcut that comes with it).

Cheers,
Tobias


#3

Hey Tobias, thanks for your response. Is it possible to have it automatically submit the “Add Result” dialogue box that pops up? This way it’s still a one click button but when the Add Result page pops up it auto submits and closes moving on to the next test case? I was not able to figure out a work around for this either. If not, I will just have to start & stop the timer manually and wait for an update in a future version.

Thanks!


#4

Hi Huston,

It should be possible to do this with a UI script and an event handler for the Add Result dialog (result_dialog.loaded) but it would be difficult to do this just for this specific purpose and not in general when the Add Result dialog opens. So, I would recommend doing this manually for now and you may not need the elapsed timer every time so you can still use the one-click Pass and Next feature.

Info about event handling for the result dialog can be found here:

Cheers,
Tobias