在代码模块访问屏幕快照

Ranorex 3.3版开始,可以直接在代码中通过对象库的Info对象访问屏幕截图。比如,你要比较你先前捕获的屏幕截图与您在运行测试时应用程序的实际界面。

7-ranorex-studio-repository-screenshot-33

在对象库中的屏幕快照

C#

// get the screenshot from the repository
Bitmap MyScreenshot = MyRepo.IconPicker.LI_IconInfo.GetScreenshot_Icon();
// create FindOptions with similarity set to 95%
Imaging.FindOptions MyFindOptions = new Imaging.FindOptions(0.95);
// compare the captured screenshot with the actual list item
Validate.CompareImage(MyRepo.IconPicker.LI_Icon, MyScreenshot, MyFindOptions);

 

VB.NET

‘ get the screenshot from the repository
Dim MyScreenshot As Bitmap = MyRepo.IconPicker.LI_IconInfo.GetScreenshot_Icon()
‘ create FindOptions with similarity set to 95%
Dim MyFindOptions As New Imaging.FindOptions(0.95)
‘ compare the captured screenshot with the actual list item
Validate.CompareImage(MyRepo.IconPicker.LI_Icon, MyScreenshot, MyFindOptions)

 

注:使用FindOptions,你可以设置自定义值,如“相似度”。此选项允许你定义一个最小的相似度,在图像区域中搜索与截图相匹配的项。进一步的细节,请参考5课:Ranorex录制器 – 基于图像的自动化

Leave a comment

请输入正确的验证码