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

Opening a comment link in new tab/window

I upload test results and links to detailed logs to TestRail. These links are in markdown syntax, something like [link] (www.theresult.url) (added separating space since this forum uses markdown). This is put into the comment field for the test result. It works to click and open the detailed log.

But this open in the same browser window/tab, which is inconvenient as it loses the current browser window, state, and all in TestRail. I now have a requirement to have the links open in new window/tab by default.

I tried various approaches from - embedding HTML into the comment field, using {target="_blank"}, using {:target="_blank}.

Nothing works. I see similar topics have been discussed and requested on the forums before: Links within Test Cases.

Any way to make this happen?

1 Like

Hello uliuli,

Thank you for posting. Currently, there is not a built-in setting in TestRail that forces links to opened in a new browser tab / window. We do have plans to review adding support for this in a future update and I have added your vote to this feature request as well. That said, we don’t have a specific timeframe/ETA to provide for this yet.

In the meantime, we would recommend using either the ctrl + click or the middle-click method to open the link in a new tab or window as needed. It may also be possible to create a UI script that would append the necessary HTML formatting to open links in new tabs. We don’t have any specific example script that we can provide to accomplish this task but if you are interested in learning more about using UI scripts, you can find more information on our website here:

I hope this helps!


Thanks John.

I created a simple UI customization script that would select all the links I am interested in, and add target="_blank" to all of them. However, I am not getting any hits on my links with the JQuery selector. Here is the UI plugin code I wrote:

name: Hello world
description: Shows a 'Hello, world!' message on the dashboard
author: Gurock Software
version: 1.0

     function() {
	console.log( "starting to modify links" );
		console.log( "modifying link:"+this );

The page I use is…

The URL’s to modify are in results & comments box as markdown. Like [link text] (link url).

In Chrome, I open the above page. Open Chrome developer console, refresh the page. I see it print all the links into the console for the page. But not the links I am interested in from the markdown in the comment box. They are visible in the UI, and clickable, but the above JQuery selector does not find them / print to console.

Question. How do I capture the markdown links from test results comments for modification in an UI plugin?

Just as a small update, it seems the TestRail page loads the different UI parts (including results and comments) using a bunch of Javascript functions triggered on document ready. So my UI plugin document.ready() function gets called before the TestRail runs its own similar functions to build the UI. And the links are not there at this time to modify.

I wrapped my function in a Javascript setTimeout(function, 2000) to have its execution delayed by 2 seconds after page load event. It works as long as the 2s time is enough for TestRail to load the page before the UI plugin starts modifying the links. But if user is fast, it wont have time to rewrite before click.

Of course, I also changed the filter also to only grab the relevant links and not all href’s or it would rewrite all TestRail internal links.

Question remains. Is there another (perhaps “official”) way to write this kind of functionality, without having to use timeouts? I expect any UI plugin has same issues.

Dear all,

I revisited this after a while to generalize a bit and while I was there, fixed some issues. I noticed TestRail loads some page elements dynamically with Ajax calls, which does not trigger the document.ready() event. The 2 second wait is also a bit long in some cases if moving fast.

So this updated version polls the UI for new matching links every second and re-writes the target to “_blank”. This reduces the delay and so far has handled also all Ajax loaded content.

name: Link modifier
description: Adds target="_blank" to matching links to open them in new window/tab
author: A Random Donkey on the Internet
version: 1.0

function add_target_blank() {
    console.log( "starting to modify links" );
        console.log( "modifying link:" +this ); = "_blank"
    setTimeout(add_target_blank, 1000)

For example, replacing MYURLPATTERN in the above with “” would rewrite all links containing that address to open in a new tab if presented inside TestRail. I use it to rewrite url’s, added to test results by automated uploader, to open in new tab.


PS: How do I add syntax highlighting as in my earlier post?