Selecting style data from DevTools in chrome - google-chrome

When I want to copy style data from DevTools with Ctrl+C I have trouble selecting text.
Why?
Before releasing the mouse pointer, the text seems selected.
After releasing the mouse pointer, the selection is gone and I get a blinking cursor (at the arrow):

It looks like you are dragging your mouse over the text in order to select it. Rather than doing that, try clicking the selector.
The entire selector will be highlighted. Now press Ctrl+C.

Related

Inspecting drop down menus in new Chrome

I'm on Chrome Version 41.0.2272.101 m (newest), and this update is messed up. They put it, when you have inspector open, that any DOM change will flash with purple on the changed element (like in Firefox), but now I cannot inspect any hovered object (also like in FF, which is why I don't like to use it when doing front end developing).
I'm talking about js triggered events, like superfish for instance. Before, I could hover the menu, and cover the menu with the inspector, and the menu would stay opened, and I could go in the inspector see what pseudoelements are created, change the paddings and such directly, and see the change. Now, when I hover the menu, and right click to inspect it, the menu closes, and I cannot inspect it!
I tried dragging the inspector over, but nothing helped. This new 'feature' is annoying as hell. Is there a way to inspect js triggered events, without putting break points on elements (which works, but is kinda pain in the ass)?
Hover over the element with your mouse and press F8 (this will only work in Chrome) to pause the script execution. The hover state will remain in visible to you. If you're on a Mac, you may have to open system preferences and check off "Use all F1,F2,etc" check box (Or simply use fn + F8).
Sometimes it only works if you are in the Sources tab of the inspector.
*Yes, you should be in the source tab and MOST IMPORTANT is you should close all the opened tabs in the Sources tab before you press F8(win) or Fn+F8(mac). *
Depending on the menu element type, I ran into this issue with drop-down input menus. The reason it's disappearing when I inspect it, is because a blur or focusout event is always triggered on the element when I click anywhere outside the element.
One way I was able to inspect the element is to prevent these events from being triggered is by removing their event listeners:
Inspect the input element on Chrome
Go to the Event Listeners tab and remove the blur or focusout event
Once the event listeners are removed, you can open the menu and inspect it without disappearing
In Chrome, press F12 to open the developer console, then click on Settings (cogwheel icon) or press F1:
then find & check the "Emulate a focused page" option.
Update: as noted in comments, this option is now in another place. See this answer.
On Mac, you can press cmd+\ to pause the script after having opened the dropdown. You can then use shift+cmd+c to inspect elements.
Adding to "In Chrome, press F12 to open the developer console, then click on Settings (cogwheel icon) or press F1:" above;
In Chrome 86 and above you can find "Emulate a focused page" option here:
DevTools >> Elements >> "Kebab" menu (3 vertical dots by the settings cog) >> More tools >> Rendering.
Alternately: With Devtools open: Hit CTRL/CMD+SHIFT+P to open the command menu HUD, enter "emulate a fo" to narrow the search results and enter (or click) to toggle the setting.
Now, when I hover the menu, and right click to inspect it, the menu
closes, and I cannot inspect it!
I faced the same issue and what I used was Expand recursively option on chrome dev tools:
The steps are:
Inspect the dropdown field
Find the dynamic DOM (the purple highlight)
Right-mouse click on that dynamic DOM
Choose Expand recursively:
We can see all elements are there
Here is a demo:
In Firefox
In Inspector, right click on a node that contains the dropdown, select:
Break on... > Subtree modification
This will pause execution the moment dropdown is... well... dropped down.
Only way that would work for me was doing setTimeout(() => { debugger }, 3000) in the console and opening the dropdown while timeout was running.
Pressing pause button in dev tools UI or F8 key to pause script execution would both close the menu.
I just used emulate a focused page and it worked like a charm
go to settings
go to more tools
find Rendering
find "emulate a focused page" and click the radio button
voala now you can inspect your select element
You can set an interval that writes out the content of a given element in the JS console every second. Drop this in the console and open the dropdown.
setInterval(() =>
console.log(document.querySelector('.Select-menu-outer').outerHTML),
1000)
None of the above referred remedies worked for me.
As our drop down (React based) will close on any single click (right or left)
So we found out the below workaround:
In Chrome Open developer tools
first click on the drop-down in collapsed state & let it expand with options
then under the element section, right-click on the div node (make sure not to left click before right clicking), which contains details of the drop-down items
Then select option 'Expand Recursively'
Then required details were shown
I think you can use the CSS Editor in Chrome to apply a state, for instance, the state of 'hover'.
In the Developer Tools, you select an element. On the right hand you have a square with an arrow over it. Click that and you can choose a state. For instance, pick hovered and you'll see both your window and your CSS update as if the element is being hovered right now.
On Windows, press F12 first, at the page with the menu, then point your mouse to the element menu (the menu will drop down), then press CTRL + Shift + C. Now you can inspect all the elements.
in my case i do following steps
Open developer tool or inspect page
click three dot button at top right
click on More tools -> Rendering
then check on Emulate a focused page option.

Selenium: How can I click through a transparent overlay?

I have an element that fires some javascript on click.
Partially covering the element is a mostly-transparent graphic, which passes all events to that element. This way, regardless of if the overlay or the element is clicked, the element gets the events.
I'm trying to write a test in selenium that clicks the element under test and verifies the behavior, however the chrome webdriver tells me it can't click the element because the overlay will get the click event.
That is fine, though... How do I tell selenium that I don't care, to click anyways? I don't want to specifically click the overlay (in this test), the overlay is just eye-candy so the test should still work even if I remove the overlay.
edit:
To make clear... I want it to click in wherever it would have, if the overlay wasn't there. this way it'll click the element if there is no overlay, but click the overlay if covered.
You will not be able to click on the object under the overlay as Selenium has been written to only access what a user can access. If a manual user cannot click through then neither can Selenium.
You could either fire JavaScript directly on that object via the javascript_executor method, or alternatively, perform the interaction which will remove the overlay in your test
I could resolve this issue: In my application top header was visible and i clicked on one of the top elements (which was visible) and could continue with rest of the script execution
I solved this issue by clicking the coordinates of the close button.
Check out this answer. I showed how to click on the little "x" there, without needing to know the name of the actual button. Sometimes its easier to find the class of the image, for example.
Worst case, find the closest element to the button and change the last method to move_to_element_with_offset(element,x, y) to go from the element you found to the coordinates of the button on screen.
Once you do that, the overlay disappears and you can click as normal.

"Inspect" a hover element?

Note: I've read similar threads, but none quite my issue - I can right click on it fine, it just then disappears.
I find 'Inspect Element' an invaluable tool in Chrome, however I'm having trouble using it for sub-menu for an element on my nav bar, which pops up below on hover of its parent item.
The popup (or down) isn't quite styled how I'd like, so I right-click > inspect element to see what's coming from where exactly, and get a better idea of how to achieve my desired effect.
However, as soon as I move my mouse away from the menu, it's gone; thus I can't select different elements in the inspection pane, and see which area is highlighted at the same time.
Is there a way around this, without changing the menu, so that it stays 'popped up' once activated?
If the hover element is triggered by JS (if triggered by CSS :hover, see gmo's answer), you can inspect it if you pause script execution. This is a much simpler way of freezing the DOM than the other answers suggest. You can pause script execution without losing the hover element as follows:
1. Via a keyboard shortcut
Here's how you do it in Chrome. I'm sure Firefox has an equivalent procedure:
Open up Developer Tools and go to Sources.
Note the shortcut to pause script execution—F8 (there may also be another depending on your OS).
Interact with the UI to get the element to appear.
Hit F8.
Now you can move your mouse around, inspect the DOM, whatever. The element will stay there.
2. Via a delayed debugger statement
Some web pages attach keydown / keypress / keyup event listeners which interfere with the shortcut above. In those cases, you can pause script execution by triggering a debugger statement while the hover is open:
Open the JS console, and enter:
// Pause script execution in 5 seconds
setTimeout(() => { debugger; }, 5000)
Trigger the hover and wait for the debugger statement to execute.
If the hover effect is given with CSS then yes, I normally use two options to get this:
One, to see the hover effect when the mouse leave the hover area:
Open the inspector in docked window and increase the width until reach your HTML element, then right click and the popup menu must be over the inspector zone... then when you move the mouse over the inspector view, the hover effect keep activated in the document.
Two, to keep the hover effect even if the mouse is not over the HTML element, open the inspector, go to Styles TAB and click in the upper right icon that says Toggle Element State...(dotted rectangle with an arrow) There you can manually activate the Hover Event (among others) with the checkbox provided.
If it's not clear at all, let me know and I can add a few screenshots.
Edited: screenshot added.
And finally and as I say at the begining, I only be able to do this if the hover is set with CSS:HOVER... when you control the hover state with jQuery.onMouseOver for example, only works (sometimes), the method One.
Hope it helps.
What worked for me is selecting the specific a tag I wanted to inspect and configure it to break on attribute modification:
After doing the above, I would again normally select that a tag then the dropdown will automatically stay as-is even when I mouseover to other places like Inspect Element, etc.
You can just refresh the browser when doing inspecting the menu dropdown elements to go back to normal state.
Hope this helps. :)
You can also do this in the javascript console:
$('#foo').trigger('mouseover');
An that will "freeze" the element in the "hover" state.
Here's how I do it with no CSS changes or JS pausing in Chrome (I am on a Mac and do not have a PC in front of me if you are running on Win):
have your developer console open.
do not enable the hover inspection tool yet, but instead open up your desired sub menu by moving your mouse over it.
hit Command+Shift+C (Mac) or Ctrl+Shift+C (Win/Linux)
now the hover inspection tool will apply to the elements you have opened in your sub-nav.
Open Inspect element
Now go to elements now on right side and select hover
It will show all hover effects
Not sure if it was present in previous browser revisions, but I just found out this extremely simple method.
Open the inspector in chrome or Firefox, right click on the element you are interested in, and select the appropriate option (in this case: hover).
This will trigger the associated CSS.
Screenshots from Firefox 55 and chromium 61.
I needed to do this, but the element I was trying to inspect was added and removed dynamically based on hover state of another element. My solution is similar to this one, but that didn't quite work for me.
So here's what I did:
Add simple script to enter debugger mode upon mouseover of the element that triggers the hover event you're concerned about.
$(document).on('mouseover', '[your-hover-element-selector]', function(e) {
debugger;
});
Then, with the dev console open in Chrome, hover over your element, and you will enter debugger mode. Navigate over to the sources section of the dev tools, and click the "Resume script execution" button (the blue play-like button below).
Once you do that, your DOM will be paused in the hover state, and you can use the element inspector to inspect all the elements as they exist in that state.
I found a very simple way to do this if for some reason you have problems with script pausing:
Open Dev Tools on "inspect"-tab.Hover to make the pop-up appear.Right-click on the desired element in your pop-up and press 'Q' (in Firefox) to inspect that element.Use keyboard to navigate: Arrow Up/Down: Move between elementsArrow Left/Right: Collapse/ExpandTab/Shift+Tab: Move between inspector and CSS rules and inside CSS RulesEnter: Edit CSS Rule
Excellent stuff!
Thank you to gmo for that advice. I did not know about those attribute settings massively helpful.
As a small revision to the wording I would explain that process as follows:
Right Click on the element you would like to style
Open 'Inspect' tool
On right hand side, navigate to the small Styles tab
Found above CSS stylesheet contents
Select the .hov option - This will give you all the settings
available for the selected HTML element
Click and Change all options to be inactive
Now Select the state that you would like to tweak - On activation of any of these, your Stylesheet will jump you directly to those settings:
Styles - Tweaking Filters - Interactive elements
This information was a lifesaver for me, cannot believe I have just heard about it!
Change the CSS so that the property which hides the menu isn't applied while you work on it is what I do.

Inspect hovered element in Chrome?

I am trying to view, through Chrome's developer tools, how tooltips are structured on a site. However, even when I am hovered over the item, when I "inspect element", nothing shows for the tooltip in the html. I know I can set the Style to :hover, but I still can't see the html or css of the tooltip.
Any ideas?
F8 will pause debugging.
On Mac, you may need to have the 'Sources' tab of the developer tools open.
Mouse over the tooltip, and press F8 while it is displayed.
You can now use the inspector to look at the CSS.
I actually found a trick to do that with the Twitter Bootstrap tooltips. If you open the dev tools (F12) on another monitor, then hover over the element to bring up the tooltip, right click as if you were to select 'Inspect Element'. Leaving that context menu open, move the focus over to the dev tools. The html for the tooltip should show up next to the element its a tooltip for in the HTML. Then you can look at it as if it were another element. If you go back to Chrome the HTML disappears so just something to be aware of.
Kind of a weird way but it worked for me so I figured I would share it.
This solution works without any extra code.
Hit command-option-j to open the console. Click the window-looking button on the top right corner of the console to open the console in a different window.
Then, in the Chrome window, hover over the element that triggers the popover, hit command-` however many times you need to focus on the console, then type debugger. That'll freeze the page, then you can inspect the element in the Elements tab.
Click f12 go to the console tab and add the following:
setTimeout(()=> {debugger},5000)
This will give you 5 seconds to do whatever you want and it will break at 5 seconds. Then you can inspect the target element
(ex. hover the element and wait 5 seconds then inspect..)
You would just need to force the tooltip to show as such
$('.myelement').tooltip('open');
Now the tooltip will show regardless of hovering state.
Scroll down near the bottom of the DOM where you should see the markup.
Update see cneuro's comment for Bootstrap 3.
$('.myelement').tooltip('show');
Update see Marko Grešak's answer for Chrome and apparently Safari as well, $0 can be used as a shortcut for the currently selected element. This appears to work in Safari as well.
$($0).tooltip('show')
Single window answer, with no coding
None of the other answers are quite right, or have enough detail, so here's my attempt.
Open Chrome's DevTools using F12/Ctrl+Shift+I (Windows/Linux) or Command+Option+I (Mac).
Select the Sources tab in the DevTools window.
Using the mouse, hover over the element you want to inspect, to make the tooltip visible.
Press F8 (Windows/Linux/Mac) to pause script execution. The main window will grey out, and a "Paused in debugger" popup will appear.
In the DevTools window, select the Elements tab
For Bootstrap tooltips, the tooltip will appear as the last <div> in the <body>
For me, the accepted answer didn't work: clicking in DevTools immediately closed the ToolTip.
However, I found https://superuser.com/questions/249050/chrome-keyboard-shortcut-to-pause-script-execution which helped me:
In the console:, Run:
const F12 = 123
window.addEventListener('keydown', function(event) {
if (event.keyCode === F12 ) {
debugger;
}
});
Highlight element with inspector
Hit F12
You can now inspect the element, with JavaScript paused so the DOM won't change.
it is so simple to edit these tooltips.
Step 1: Inspect the element that has the tooltip. Make sure it is highlighted with blue in devtools.
Step 2: right-click on the element (in devtools part) and select: attribute modifications, under Break on
Step 3: Hover over the inspected element and a gray overlay will appear over the site with a small text: Paused in debugger
at the top of your screen
Step 4: Click on the blue arrow until the hover state is selected.
Step 5: Inspect and edit the tooltip
No code solution for JS activated tooltips:
With Chrome's devtools inspect the containing / parent element of the tooltip. In the "elements" tab, right click on that container DOM element then choose "break on" > "subtree modifications". The next time you hover over the part of the DOM the tooltip is housed in, the JS code will be paused allowing you to inspect the contents of the tooltip.
Follow these steps
Open Inspect window in chrome.
Place the mouse over the tooltip.
Press F8
JS execution will be paused and then you can inspect the tooltip.
Press F8 again to start execution and F10 to debug.
Here is how I did it on Mac:
Hover over the element that has a tooltip with chrome devtools opened.
Wait for the tooltip to appear.
Open devtools command palette with a keyboard shortcut. Cmd+Shift+P worked for me.
Type in Disable JavaScript and press Enter
This will prevent from fading all the tooltips that utilize JavaScript.
Hover over the element, press F8 for little longer, it will pause script execution.
Here’s a simple solution: If you have dynamic tooltips, you can make them “persistent” by (temporarily) changing the trigger event to click. This will have the effect that the tooltip only disappears on a click-out:
$('body').tooltip({
selector: "[data-toggle='tooltip']",
trigger: "click"
});
This way, it can be easily inspected with FF’s or Chrome’s debugging tools.
1)Open the Inspect window by clicking F12
2)Go to source tab(next to console)
3)Now hover on element to be inspected and keep your mouse over there.
4)Using keyboard(Tab or shift+tab) to move the control to pause button or F8Refer the image
5)When keyboard focus is on Play button. Hit enter. Your hover element will be freezed you can do anything now
just hit one line script in console and press any key to enter in debug mode.
window.onkeydown = () => { debugger }
The dev tools provides a way to inspect a hovered element like a tooltip.
1 - Open the dev tools using F12.
2 - Select "Elements" tab.
3 - Select the parent element that contains the tooltip.
4 - Click on "..." (on the line of the parent element) and after select "Break on"/"subtree modifications" (see image below)
5 - Finally go back to application and make the Tooltip shows up. It should block the execution after the Tooltip gets visible
Hope it can be useful for someone!
appear the hovered item by over mouse
windows --> Ctrl + shift + c || Mac --> Command + Option + C
I had problems with this so I went to the documentation and inspected the tooltip that is already rendered on the page. That helped me see the dom structure of the tooltip and edit it accordingly.
In Chome on Linux this can be achieved for JS generated tooltips such as those for references on WikiPedia by doing the following:
As stated above, open the dev tools using F12. Open them in another window.
Highlight the tooltip and click Ctrl-Shift-C (The HTML Inspector). As you move over the tip, the dev window will show the appropriate section.
If you need to keep the tip open when you mouse off it, to be able to inspect it in the other window more thoroughly, then right click on the tooltip and leave the context menu up, and click on the the dev tools window. In this scenario it leaves the tip up in the wikipedia window.
To a degree it also works with bootstrap tips.
For some reason the answers provided here weren't working for me on Windows. I was able to inspect the tooltip by opening the dev tools, then hovering over the element that brings up the tooltip, then right clicking on that element (not the tooltip). Then, move the cursor over into the inspector panel and scroll down to the bottom. The tooltip element should still be there.
Another Solution I found for this problem. Through Mobile or Tablet view in Chrome
press Crt + Shift + M in Chrome Dev tools for Mobile view in Chrome.
Click(Tap) on ToolTip div and you can inspect it with Right Click on tooltip
Hit command-option-j to open the console. Click the window-looking button on the top right corner of the console to open the console in a different window.
Then, in the Chrome window, hover over the element that triggers the popover, hit command- however many times you need to focus on the console, then type debugger. That'll freeze the page; then you can inspect the element in the Elements tab.
I found a good way I was struggling with this :
• Open Elements Tab
• Inspect an element on the page , should be close to the element that you are trying to inspect
• Hover over the tooltip
• While the dev/Elements tab is open Hit Ctrl F to move the focus to Text area in element tab where it Says Find by string , selector , or Xpath
• use the keyboard key to navigate up/down the elements till you will get to the elements that you are looking for , dont touch your mouse
Land in this post for answers and find eventually a way to do it. Inspect the parent element of tooltip and set break on subtree change and hover your mouse on element and click F8 till the tooltip appear. You can have your tooltip and check the styling.
some tooltips disappeared when we open the inspect part on hover mode, sometimes they don't disappear when change responsive tab (active or inactive button).
then you can right click and get inspect from it.so easily.
Worth noting that toggling the :hover state from within the dev tools only has an impact if the hint text is enabled via CSS :hover rules in the first place. The toggle only applies the hover state to the element for rendering purposes, but does not trigger a corresponding JavaScript mouseover event.
Many frameworks such as AngularJS dynamically attach tooltip HTML to the bottom of the document body via JavaScript when a target element is hovered, so any amount of hovering and inspecting the target element won't help.
#joeyyang's answer worked very well for me in this scenario.
One of the easiest ways I found is:
Open Chrome dev tools on the side
Hover over element
Right-click
Click on dev tools
Now you can inspect and change styles

Putting a input[type=text] inside a label behaves oddly in Firefox (only)

Take a look at this sample: http://jsbin.com/imivek/1/edit
Clicking the text field, which is part of the label, behaves oddly in Firefox (tested in v17.0.1):
Clicking it once will give it focus for a very brief period of time, after which the focus moves to the radio button.
Clicking it twice shortly after each other will maintain focus.
Focusing it by other means (f.e. tab) will work fine and as expected.
Handling the text field's click event and preventing it from bubbling up (e.stopPropagation() in jQuery terms) doesn't change anything.
Who can explain this behavior and recommend how to best work around it?
You may have only one form control inside a label. You have two. Your HTML is invalid so weird behaviour is to be expected as browsers attempt to compensate for your mistake.
Clicking it once will give it focus for a very brief period of time, after which the focus moves to the radio button.
You clicked on the label. That sets the focus to the radio button (since the label appears to be a label for it).
Clicking it twice shortly after each other will maintain focus.
Probably some sort of error recovery
Focusing it by other means (f.e. tab) will work fine and as expected.
You aren't clicking the label then
Handling the text field's click event and preventing it from bubbling up (e.stopPropagation() in jQuery terms) doesn't change anything.
It is native functionality, not scripted functionality.
Write valid HTML.
Why do you have two <input>'s in the same <label>? What are you trying to do? A label is supposed to be bound to one input element and act as a caption for it, so that when you click it, the input takes focus.
This is a FF bug
https://bugzilla.mozilla.org/show_bug.cgi?id=213519
Reported in 2003, still not fixed!