Chrome Dev Tools: How to trace network for a link that opens a new tab?

Google ChromeGoogle Chrome-Devtools

Google Chrome Problem Overview


I want to trace the network activity that happens when I click on a link. The problem is that the link opens a new tab, and apparently the Dev Tools works per tab it was open for. "Preserve Log Upon Navigation" does not help.

My current solution is to move to FireFox and HttpFox which does not have this issue. I wonder how all the developers for Chrome manage, this sounds pretty basic (of course I've searched for the answer, didn't find anything helpful).

Google Chrome Solutions


Solution 1 - Google Chrome

Check out chrome://net-internals/#events (or chrome://net-export in the latest version of Chrome) for a detailed overview of all network events happening in your browser.


Other possible solution, depending on your specific problem, may be to enable 'Preserve log' on the 'Network' tab:

DevTools > Network > Preserve log

and force all links to open in the same tab by executing the following code in the console:

[].forEach.call(document.querySelectorAll('a'),
    function(link){
        if(link.attributes.target) {
            link.attributes.target.value = '_self';
        }
    });

window.open = function(url) {
    location.href = url;
};

Solution 2 - Google Chrome

The feature request mentioned in the comment by phsource has been implemented.

In recent versions (starting with Chrome 50), you can go to the Developer Tools Settings menu (open Developer Tools, then use the 3-dots menu or hit F1) and check the box that says "Auto-open DevTools for popups".

Solution 3 - Google Chrome

In Chrome 61.0.3163.100 you now have the following option available. It is accessed by going to the Chrome Dev Tools Settings. It's at the bottom.

Web Inspector settings

Solution 4 - Google Chrome

In Chrome 85 (still valid in Chrome 100) "Auto-open DevTools for popups" is hidden in a new place

DevTools (F12)/Settings (F1, Ctrl + ?)/Preferences/Global (at the end of the list)

enter image description here

And now it keeps the "Preserve log" setting.

Solution 5 - Google Chrome

You can do it this way :

  1. set target="any_window_name" on wanted link.

  2. click on that link once, to open it in new tab.

  3. In opened tab, open developer tools.

  4. go back to origin page and hit that link again.

    The result will be loaded in already prepared window with developer tools opened.

    You can activate "preserve log" option in dev tools (see in Konrad Dzwinel excellent answer) to catch any redirect traffic on that link.

    Note : most people familiar with link target ∈ { _self,_blank,_parent,_top }. But actually any name can be given, this will open a new window with that name, and any subsequent clicks on links,forms or window.open with same target value will be opened in same window. further reading - mdn : window.open , mdn : <a> tag

Solution 6 - Google Chrome

  • Add/update the link to target="_self"
  • Check "preserve logs upon navigation" in Network tab.
  • Click on the link and gets your request logged

Solution 7 - Google Chrome

In case the opened link does not redirect, you can open the Network tab in the new tab then refresh the tab.

Solution 8 - Google Chrome

Quickly hit F12 when new tab opens

https://stackoverflow.com/a/13747562/660408

Works for me when I monitor Google Drive download responses

Solution 9 - Google Chrome

*** Disclaimer: Posted by Developer of HttpWatch ***

HttpWatch on Windows can record the network traffic generated when a new Chrome tab or window is opened by enabling auto-recording in Tools->Options->Recording. In the new window click on the HttpWatch icon to view the network trace.

The free version will provide basic information such as URL, status code and elapsed time for each request.

*** Disclaimer: Posted by Developer of HttpWatch ***

Solution 10 - Google Chrome

I would just let the new tab open, do a F12 and refresh the tab so it logs in the devtools window

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondavkaView Question on Stackoverflow
Solution 1 - Google ChromeKonrad DzwinelView Answer on Stackoverflow
Solution 2 - Google Chromeuser2404501View Answer on Stackoverflow
Solution 3 - Google ChromeKonrad PiascikView Answer on Stackoverflow
Solution 4 - Google ChromeTomView Answer on Stackoverflow
Solution 5 - Google ChromeMichael L.View Answer on Stackoverflow
Solution 6 - Google ChromeSebastien LorberView Answer on Stackoverflow
Solution 7 - Google ChromeorgadsView Answer on Stackoverflow
Solution 8 - Google ChromegkikoView Answer on Stackoverflow
Solution 9 - Google ChromeHttpWatchSupportView Answer on Stackoverflow
Solution 10 - Google ChromeCaptain_SlowView Answer on Stackoverflow