Selecting elements for screenshotting based on tag content
See original GitHub issueSelecting elements as the target for screenshots based on CSS selectors does not (currently) allow for the selection of elements based on tag content, or relative to DOM elements selected based on tag content.
However, elements can be selected based on tag content using Javascript. It would be useful to allow for the selection of elements via Javascript as well as CSS.
Alternatively, support a method that can be called from a javascript
scraper call that will apply a screen shot to a Javascript selected element.
At the moment, selector based screenshots seem to be focused in _selector_javascript(selectors)
by:
As well as passing --selector
(s), s
, one approach might be to pass element(s) el
returned from a --js-selector
script?
Issue Analytics
- State:
- Created 2 years ago
- Comments:21 (16 by maintainers)
Top Results From Across the Web
How to capture the screenshot of a specific element rather ...
This program captures the screenshot of the whole page and crop the element based on its location. The element image will be available...
Read more >I want the screenshot of only a specific element and ... - Edureka
I want the screenshot of only a specific element and not the entire page Is it possible with Selenium Webdriver.
Read more >How To Select HTML Elements Using ID, Class, and Attribute ...
You can do this broadly with an element selector to select high-level tags, but to gain ... To begin, open index.html in your...
Read more >Select Page Elements | Basic Guides | Guides | Docs - TestCafe
Select Page Elements. You should identify the target page element to perform an action with it (click, drag, etc.) or check its state...
Read more >Harvesting the web with rvest - Tidyverse
You can right-click the element you want to inspect and select Inspect or Inspect Element, depending on your browser. This will open Developer...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
OK, I built a protoype. @psychemedia you can try it out by running:
Here’s a demo:
Which produced this image (of the first paragraph on the page to contain the term
shot-scraper
):Note that I had to include
el.tagName == "P"
in the expression - because it scans through every tag on the page, so without that it returns thehtml
tag since that includes theshot-scraper
text somewhere in itsinnerText
!The demo also currently outputs debug info showing the JavaScript it generated - I’d remove that before shipping the feature:
Documentation: https://github.com/simonw/shot-scraper/blob/59b156ddd7963fd19edca214edc0ac59552efbb2/README.md#specifying-elements-using-javascript-filters