I am trying to take screenshot of the Pega web application. Can you please tell me how to use the above given code script and take a screenshot ? Also there is something called GetScreenshot method, if someone can tell me how to use that will also be great.
You add this code to the Script component available on the Advanced tab in the toolbox. The part in Ryan's reply below the bold Result Type bool goes into the main area. The sections above are filled in to their corresponding labels as shown in my screenshot.
Once you have added the method to the script container, you can then click on the script container in the Object Explorer window and see your new method on the Methods section. This method takes in 4 parameters;
string outputImagePath (the full path and file name to where you want to save the file), int width (the width you'd like the screenshot to be), int height (the height you want the screenshot to be), int xCoordinate (the x coordinate where you want to start the rectangle), int yCoordinate (the y coordinate where you want to start the rectangle).
You are on the right path by adding log messages into the script. That is the only way to debug a script. Make sure your outputImagePath is a full file name (something like C:\temp\image.png). If you have access to Visual Studio, you can execute the code within Visual Studio and use their debugger to go through it, but usually adding log messages for something as simple as this is the way to go. If the logs are too intimidating, you can also add message boxes (call the static method "MessageBox.Show("some message"); "). This can also be used to help you determine where it is failing.
I am trying the same code and it always returns a true result. The file also gets created, but it is blank. I have tried with various combinations for the coordinates and the dimensions but there is no image.
I am just trying to go to google, enter test as the string and hit enter. In the search results page I am taking the screen-shot. Attached is the Google automation and the blank image that is getting created
It looks like you are giving coordinates where on the screen, Google is blank. Try loading a more dynamic webpage where there are no blank areas. I suspect you are just providing the wrong coordinates.