This is a migrated thread and some comments may be shown as answers.

Best way to save a screenshot of an element?

5 Answers 24 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Aaron
Top achievements
Rank 1
Aaron asked on 23 Nov 2016, 06:07 PM

I have a few tests in my suite, and the only way I can really verify that something is occuring the way it is supposed to, is by saving a screenshot of that specific element area and comparing it to another file.

I have custom implemented code that handles the actual comparison itself exactly how I want to.

The thing I'm having the most issue with is trying to figure out the best way to take a screenshot of the element I'm comparing. It is a div with a bunch of img's inside of it.

I basically want to be able to screenshot the div, with all of the img's inside it, and compare that screenshot to a predetermined image.

Any help pointing me in the right direction would be appreciated.

5 Answers, 1 is accepted

Sort by
0
Aaron
Top achievements
Rank 1
answered on 25 Nov 2016, 08:26 PM

I guess I should point out that I have tried using the GetRectangle() method on the highest level DIV that contains the elements that I want, and then using that Rectangle() to save an image.

This worked at first, however at some point it started saving images that were not what was currently on the screen (it was saving previously displayed stuff). I tried fixing this by updating the DOM in code before getting the Rectangle, but this didn't seem to help at all.

0
Elena
Telerik team
answered on 28 Nov 2016, 04:43 PM
Hello Aaron,

Thank you for contacting us sharing that much details. 

In a coded step you do not need to use GetRectangle(). Instead you could apply the following row of code against any of the already existing elements in the Elements repository: 

Pages.Google.BtnKSubmit.Capture(@"C:\", "NewFile");

where you put the folder location and the file name as parameters. This will get a *.bmp image of the element in question to compare it with the custom code you have. 

Regards,
Elena Tsvetkova
Telerik by Progress
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
test
Top achievements
Rank 1
answered on 22 Mar 2019, 08:54 AM
How write the code for capture the screen shots
I have used the following steps, but every time i am getting the pop-up with "Ok" button. if i click on the ok button only am getting the screen shot.
If i am have 11 steps.. if i used the below code for 2 steps.. than the remaining steps are not executing. 
//Log.CaptureBrowser(ActiveBrowser, "Dashboard");
Other one:
 //ITakeScreenshot ActiveBrowser = null;
 //Screenshot SS = ((ITakeScreenshot)ActiveBrowser).GetScreenshot();
 //SS.Savefile("D:\\Telerik_Test_Studio\\Hudson\\Dashboard.png", System.Drawing.Imaging.ImageFormat.Png);
0
test
Top achievements
Rank 1
answered on 22 Mar 2019, 08:55 AM
How write the code for capture the screen shots
I have used the following steps, but every time i am getting the pop-up with "Ok" button. if i click on the ok button only am getting the screen shot.
If i am have 11 steps.. if i used the below code for 2 steps.. than the remaining steps are not executing. 
//Log.CaptureBrowser(ActiveBrowser, "Dashboard");
Other one:
 //ITakeScreenshot ActiveBrowser = null;
 //Screenshot SS = ((ITakeScreenshot)ActiveBrowser).GetScreenshot();
 //SS.Savefile("D:\\Telerik_Test_Studio\\Hudson\\Dashboard.png", System.Drawing.Imaging.ImageFormat.Png);
0
Elena
Telerik team
answered on 25 Mar 2019, 04:10 PM
Hello,

You have submitted your query into another public forum item - to avoid any duplication in the discussion, I suggest we keep the conversation in the other ongoing thread here

Thank you for your understanding in advance. 

Regards,
Elena Tsvetkova
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Aaron
Top achievements
Rank 1
Answers by
Aaron
Top achievements
Rank 1
Elena
Telerik team
test
Top achievements
Rank 1
Share this question
or