Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I inspect disappearing element in a browser?

How can I inspect an element which disappears when my mouse moves away? Example dropdown which disappears

I don't know it's ID, class or anything but want to inspect it.

Solutions I have tried:

Run jQuery selector inside console $('*:contains("some text")') but didn't have any luck mainly because the element is not hidden but probably removed from the DOM tree.

Manually inspecting DOM tree for changes gives me nothing as it seems to be just too fast to notice what have changed.

SUCCESS:

I have been successful with Event breakpoints. Specifically - mousedown in my case. Just go to Sources-> Event Listener Breakpoints-> Mouse-> mousedown in Chrome. After that I clicked the element I wanted to inspect and inside Scope Variables I saw some useful directions.

like image 491
lukas.pukenis Avatar asked Oct 17 '22 05:10

lukas.pukenis


People also ask

How do I view hidden elements on a website?

Click Modify | <Element> tab Reveal Hidden Elements panel (Unhide Element) or (Unhide Category). Right-click the element, and click Unhide in View Elements or Category.

How do I inspect text hidden element?

In Chrome, Safari, Opera and Firefox (with Firebug add-on) right click and choose Inspect Element (or Inspect Element with Firebug) and it will show you all elements and the style rules that apply to them. The Web Developer Toolbar for Firefox has a “Show hidden elements” option under the “Miscellaneous” menu.

How do I inspect element hide on mouse click?

Look for the div with class ytp-settings-menu in developer tool Element tab and then uncheck the Style display: none;, you will be able to see the setting menu.


2 Answers

(This answer only applies to Chrome Developer Tools. See update below.)

Find an element that contains the disappearing element. Right click on the element and apply "Break on... > Subtree Modifications." This will throw a debugger pause before the element disappears, which will allow you to interact with the element in a paused state.

enter image description here

Update Oct 22 2019: with the release of v. 70, it looks like FireFox finally supports this kind of debugging 2 3:

enter image description here

Update Sep 15 2020: Chrome has an "Emulate a focused page" option (you can get it from the [⌘]+[P] Command Menu, or Global Preferences) for this exact need. 5 - h/t @sulco on Twitter

like image 142
americanyak Avatar answered Oct 22 '22 23:10

americanyak


An alternative method in Chrome:

  • Open devTools (F12).
  • Select the "Sources" tab.
  • While the element you want is displayed, press F8 (or Ctrl+/). This will break script execution and "freeze" the DOM exactly as it is displayed.
  • From this point, use Ctrl+Shift+C to select the element.
like image 25
Joseph Tinoco Avatar answered Oct 23 '22 00:10

Joseph Tinoco