Udontknow
Udontknow

Reputation: 1580

Screenshot from AutomationElement with .Net Automation Testing

I am using System.Windows.Automatition.UiTesting assembly to start several processes and analyse their main window. How do i create a screenshot of the window shown?

Process process = new Process();
process.StartInfo.FileName = ExecutablePath;
if (!process.Start()){
    throw new Exception.Create("Could not start Process.");       
}    
Thread.Sleep(TimeSpan.FromSeconds(10));
process.Refresh();
AutomationElement mainWindow = AutomationElement.FromHandle(process.MainWindowHandle);
var imageFromWindow = ...?

The window may be (partially) hidden by other windows.

Upvotes: 1

Views: 911

Answers (1)

Rekshino
Rekshino

Reputation: 7325

The element must be visible, then you can get the coordinates of it in BoundingRectangleProperty and get a screenshot as described here:

Is CopyFromScreen a right way to get screenShots?

Upvotes: 1

Related Questions