如何做基于图像的自动化
如果Ranorex不能明确地识别某些你的GUI元素,那么使用基于图像的机制来自动化它们将会大有帮助。
C#
// Create bitmap to search for // within application form and // click it Bitmap bmp = Ranorex.Imaging.Load( @"..\..\Green Sea Turtle Small.bmp"); // Performs a right click on the image found // within the application window based on // the image location myRepo.WinFormsApp.Self.Click(MouseButtons.Right,bmp);
// You can also search for images that are slightly different to the // loaded image by specifying the minimum Similarity for a match (95% = 0.95). myRepo.WinFormsApp.Self.Click(new Location(bmp, new Imaging.FindOptions(0.95)));
// OR Set the default Similarity value for all following image operations Imaging.FindOptions.Default.Similarity = 0.95; myRepo.WinFormsApp.Self.Click(bmp);
Report.Success("Image found and clicked successfully");
VB.NET
' Create bitmap to search for ' within application form and ' click it Dim bmp As Bitmap = Ranorex.Imaging.Load("..\..\Green Sea Turtle Small.bmp") ' Performs a right click on the image found ' within the application window based ' on the image location myRepo.WinFormsApp.Self.Click(MouseButtons.Right, bmp)
' You can also search for images that are slightly different to the ' loaded image by specifying the minimum Similarity for a match (95% = 0.95). myRepo.WinFormsApp.Self.Click(new Location(bmp, new Imaging.FindOptions(0.95)))
' OR Set the default Similarity value for all following image operations Imaging.FindOptions.Default.Similarity = 0.95 myRepo.WinFormsApp.Self.Click(bmp)
Report.Success("Image displayed successfully")

浙公网安备 33010602011771号