Ask a Question

Creating multiple regional checkpoints

Louis
Contributor

Creating multiple regional checkpoints

I wish to create a regression test script for my application. I have figured out the best checkpoint type for me to use are regional ones, however my application will require 11 of these per page of data with the maximum number of pages being 96. Is there a way to get testcomplete to automatically create the reference regional checkpoints. Or will i have to manually create each one
1 REPLY 1
AlexanderM
Staff


Hi,





To automate checkpoints creation for one page, I suggest that you use the approach described below:





1. Create the "regions1.txt" file containing regions parameters, for example:







10,10,10,20

...

25,13,100,100







This file should contain regions parameters - you should specify them in the same order as they are specified for the Picture method. To successfully perform the next step, make sure that this file does not contain empty strings.





2. From TestComplete, run the script below:





    /JScript

    function GenerateCheckpoints()

    {

    var code = "";

    var obj = <...>; // Specify here the full path to the object for which checkpoints will be created

    var f = aqFile.ReadWholeTextFile("c:\\regions1.txt", 20);

    var rects = f.split(chr(13)+chr(10));

    for (var i = 0; i < rects.length; i++)

    {

        var x = rects.split(",")[0];

        var y = rects.split(",")[1];

        var width = rects.split(",")[2];

        var height = rects.split(",")[3];

        Regions.AddPicture(obj.Picture(x, y, width, height), "Image"+i);

        code = code + "Regions.Compare(\"Image"+i+"\", obj.Picture("+x+", "+y+", "+width+", "+height+", false));" + chr(13) + chr(10);

    }

    Sys.Clipboard = code;

}







This code fills the Stores collection with images and generates ready-to-use code (it will be in the clipboard right after executing).





Having several regionsN.txt files and having modified the GenerateCheckpoints routine a bit, you will be able to automate checkpoint creation for other pages.





See the 'Regions.AddPicture' and 'Regions.Compare' help topics for the method's usage information.
-----

Alexander
Customer Care Manager
cancel
Showing results for 
Search instead for 
Did you mean: