Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the CSS Selector in Chrome?

I want to be able to select/highlight an element on the page and find its selector like this:

div.firstRow div.priceAvail>div>div.PriceCompare>div.BodyS

I know you can see the selection on the bottom after doing an inspect element, but how can I copy this path to the clipboard? In Firebug I think you can do this, but don't see a way to do this using the Chrome Developer Tools and search for an extension did not turn-up anything.

This is what I am trying to do for more reference: http://asciicasts.com/episodes/173-screen-scraping-with-scrapi

like image 313
kale Avatar asked Dec 21 '10 14:12

kale


People also ask

Where is the CSS selector in Chrome Developer Tools?

Press F12 to open up Chrome DevTools. Elements panel should be opened by default. Press Ctrl + F to enable DOM searching in the panel. Type in XPath or CSS selectors to evaluate.

How do I show CSS in Chrome?

On Chrome's Developer Tools tab (CTRL + SHIFT + I), go to Resources (you may have to enable Resource tracking on that page), and click on the sub-tab Stylesheets. That will show all css files loaded by that page.

How do I find my CSS path?

If Chrome Dev tools if you select the element in the source pane and right click, then you will see the "Copy CSS Path" option. In newer versions of Chrome, this is (right-click) > Copy > Copy selector .

How do I find my CSS path in Chrome console?

Press F12 to open Chrome Developer Tool. In "Elements" panel, press Ctrl + F. In the search box, type in XPath or CSS Selector, if elements are found, they will be highlighted in yellow.


2 Answers

Chrome Dev Tools CSS Path

If Chrome Dev tools if you select the element in the source pane and right click, then you will see the "Copy CSS Path" option.

In newer versions of Chrome, this is (right-click) > Copy > Copy selector.
You can also get the XPath with (right-click) > Copy > Copy XPath

like image 82
Carlos Cervantes Avatar answered Oct 14 '22 09:10

Carlos Cervantes


Although not an extension, I did find a bookmarklet called Selector Gadget that does exactly what I was looking for.

like image 30
kale Avatar answered Oct 14 '22 09:10

kale