# Taking screenshot of a selected WebElement

**URL:** <https://forum.katalon.com/t/taking-screenshot-of-a-selected-webelement/13567>\
**Category:** Tips and Tricks\
**Tags:** tips-tricks, katalon-studio\
**Created:** [October 4, 2018, 10:06pm UTC](https://forum.katalon.com/t/taking-screenshot-of-a-selected-webelement/13567 "2018-10-04T22:06:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [October 4, 2018, 10:06pm UTC](https://forum.katalon.com/t/taking-screenshot-of-a-selected-webelement/13567/1 "2018-10-04T22:06:07Z")

</div>

I have made a demo project on GitHub:

- [GitHub - kazurayam/TakingScreenshotOfSelectedWebElement: Taking screen shot of a selected WebElement using AShot in Katalon Studio](https://github.com/kazurayam/TakingScreenshotOfSelectedWebElement)

**Problem to solve**

This project proposes a solution to [a discussion posted at Katalon Forum](http://forum.katalon.com/discussion/5010/take-screenshot-only-in-the-selected-area). The original question was:

> I want to screen only the parts of a website, which I can see on my desktop. The Katalon screenshot command will screenshot a big part of the website. It would be great if I could decide which parts of a website the screenshot should take.

[aShot](https://github.com/yandex-qatools/ashot), a WebDriver Screenshot utility, provides an immediate solution to this.

This project shows you how to use aShot in a Katalon Studio project, and provides a working example of taking a screenshot of a selected HTML element in a Web page.

## How to run the project

1. download the zip of this project at [https://github.com/kazurayam/TakingScreenshotOfSelectedWebElement/releases](https://github.com/kazurayam/TakingScreenshotOfSelectedWebElement/releases "Link: https://github.com/kazurayam/TakingScreenshotOfSelectedWebElement/releases")
2. unzip it. you get the project folder
3. start Katalon Stuio, open the project
4. open `Test Cases/TC1` and run it with your favorites browser
5. the test script will open [Katalon Forum](http://forum.katalon.com/discussions) and take screenshot of the banner
6. when the test script finished, you will find a PNG file `<projectDir>/tmp/forum-banner.png`

The screenshot would look like this: [![forum-banner](https://europe1.discourse-cdn.com/katalon/original/3X/0/f/0f6c404eafe128c28f143979c0bc26f5ad13fbf2.jpeg "Image: https://github.com/kazurayam/TakingScreenshotOfSelectedWebElement/raw/master/tmp/forum-banner.png")](https://github.com/kazurayam/TakingScreenshotOfSelectedWebElement/blob/master/tmp/forum-banner.png)

## Codes

Please read the source codes and see what I did.

1. [Test Cases/TC1](https://github.com/kazurayam/TakingScreenshotOfSelectedWebElement/blob/master/Scripts/TC1/Script1538686539182.groovy)
2. [Keywords/com.kazurayam.ksbackyard.ScreenshotdriverMini](https://github.com/kazurayam/TakingScreenshotOfSelectedWebElement/blob/master/Keywords/com/kazurayam/ksbackyard/ScreenshotDriverMini.groovy "Link: https://github.com/kazurayam/TakingScreenshotOfSelectedWebElement/blob/master/Keywords/com/kazurayam/ksbackyard/ScreenshotDriverMini.groovy")

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [October 5, 2018, 2:04am UTC](https://forum.katalon.com/t/taking-screenshot-of-a-selected-webelement/13567/2 "2018-10-05T02:04:02Z")

</div>

as usual +1

---

<div class="post-metadata">

**Author:** ![vishalk.singh](https://avatars.discourse-cdn.com/v4/letter/v/ad7895/32.png) [@vishalk.singh](https://forum.katalon.com/u/vishalk.singh)\
**Post date:** [June 23, 2020, 8:30am UTC](https://forum.katalon.com/t/taking-screenshot-of-a-selected-webelement/13567/3 "2020-06-23T08:30:29Z")

</div>

Very helpfull @kazurayam but a screenshot is not attaching to the pdf report. please help how to attach it to the pdf report.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [June 23, 2020, 10:21am UTC](https://forum.katalon.com/t/taking-screenshot-of-a-selected-webelement/13567/4 "2020-06-23T10:21:24Z")

</div>

Nothing I can do.

PDF report is created by the [Basic Report plugin](https://store.katalon.com/product/59/Basic-Report). This plugin is not customisable at all.

---

<div class="post-metadata">

**Author:** ![albert.vu](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/albert.vu/32/20595_2.png) [@albert.vu](https://forum.katalon.com/u/albert.vu)\
**Post date:** [August 8, 2022, 7:32am UTC](https://forum.katalon.com/t/taking-screenshot-of-a-selected-webelement/13567/5 "2022-08-08T07:32:03Z")

</div>


