As discussed in Important notes about Screenshots in Selenium 2 and Selenium 3 we can take only visible area screenshot using TakesScreenshot interface.
To take the full page screenshot of a page AShot() scrolls down the page at particular time intervals “scrollTimeOut” till the bottom of the page and takes the screenshot of entire page.
Using shootingStrategy() method Ashot() takes the entire page screenshot. The syntax is:
Ashot() is a third party utility supported by Selenium WebDriver
to capture the screen shots. The below are the features supported by aShot() utility with repect to screenshots:
- Capturing the entire page
- Capture the Web Element
- Prettifying the screenshot
- Screenshot comparison
- Several elements comparison
To take the full page screenshot of a page AShot() scrolls down the page at particular time intervals “scrollTimeOut” till the bottom of the page and takes the screenshot of entire page.
Using shootingStrategy() method Ashot() takes the entire page screenshot. The syntax is:
Here, “scrollTimeOut” time interval. If scrollTimeOut is
1000 ms, AShot() scrolls for every 1000 ms till the bottom to capture the
image. You can observe that during script execution.
And the below line of code is to save the screenshot in the desired
location.
Let us see now how to implement it.
Step 1: Download AShot () jar file from here and add it to
the project.
Step 2: Create a simple test, below is the test that
launches ‘Selenium Babu’ blog and takes it's full page screenshot.
Step 3: The screenshot will be saved in the “screenshots” folder in
the project directory. The below video shows the execution of the script and how the screenshot is captured.
If "scrollTimeOut" is increased to 1000 ms or 2000 ms, the screen will be scrolled slowly.
Nice one bro.
ReplyDeleteThanks Bharath. Keep visiting :)
Deletebeautifully done...
ReplyDeleteThanks Sandeep. Glad to hear that, keep visiting :)
DeleteHi Venkat,
ReplyDeleteI am getting this below error .
RuntimeException: org.openqa.selenium.WebDriverException: waiting for evaluate.js load failed
do you an idea how to fix this?
Hi Atul,
DeleteaShot uses jQuery by default to find out the elements coordinates.But some drivers have problems with Javascript execution such as OperaDriver. In this case there is another way to find the WebElement's coordinates.
new AShot()
.coordsProvider(new WebDriverCoordsProvider()) //find coordinates with WebDriver API
.takeScreenshot(webDriver, myWebElement);
How much amount of time we need to configure in the scroll timeout. Suppose we are giving 1 millisecond time so with that one millisecond it has to take screenshot since for every millisecond the scroll action occurs.so, taking the screenshot of a webpage by that method happens in what amount of time.Is it lest than millisecond or greater than that time/
ReplyDeleteIf you've been an internet marketer for any amount of time you will eventually want to create some tutorials to help promote your website. screenshot guide
ReplyDeleteHow can I use it with python?
ReplyDelete