Best way to save a screenshot of an element?

6 posts, 0 answers
  1. Aaron
    Aaron avatar
    58 posts
    Member since:
    May 2016

    Posted 23 Nov 2016 Link to this post

    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.

  2. Aaron
    Aaron avatar
    58 posts
    Member since:
    May 2016

    Posted 25 Nov 2016 in reply to Aaron Link to this post

    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.

  3. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    1051 posts

    Posted 28 Nov 2016 Link to this post

    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!
  4. test
    test avatar
    3 posts
    Member since:
    Nov 2015

    Posted 22 Mar in reply to Elena Tsvetkova Link to this post

    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);
  5. test
    test avatar
    3 posts
    Member since:
    Nov 2015

    Posted 22 Mar in reply to Elena Tsvetkova Link to this post

    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);
  6. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    1051 posts

    Posted 25 Mar Link to this post

    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!
Back to Top