Forum Discussion

TMUGHILENDRAN's avatar
TMUGHILENDRAN
Occasional Contributor
8 years ago

Run Testcases As Baseline and Testline

Hi,

 

I need to Run a script in testcomplete as Baseline and Testline options.

So When I set that as Baseline it will save all the image of the testcases and save it in a proper location,

and when i select as Testline it will run the same testcases but it will compare the image that have been saved before.

Is it possible to do with TestComplete.

 

Thanks in Advance.

  • tristaanogre's avatar
    tristaanogre
    8 years ago

    I guess the point I'm trying to make is that, yes, you can do what you're asking... but it's not an "out of the box" functionality.  For what you're asking, you're going to need to write some of your own code to save the files in order to update the baselines and then utilize those saved files in running your tests.  So, I envision a function that would look something like this:

    function imageComparison(testObject, filePath, fileName) {
        //Create a project variable called updateBaseline and make it boolean. 
        //When you want to update your baselines, set it to true
        var pictureBaseline = Utils.Picture();
        if (Project.Variables.updateBaseline) {
            testObject.Picture().SaveToFile(filePath + fileName);
        }
        else {
            pictureBaseline.LoadFromFile(filePath + fileName);
            pictureBaseline.Compare(testObject.Picture())
        }
    }

    So, instead of using the built in Regions.Compare or Regions.Check, you would use the above method.  If the project variable is set to true, your baseline files will be updated... if it's set to false, you'll do the comparison.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    The first run through you'll have to create all your baselines manually.  You can start with utilizing the Visualizer feature of TestComplete.  You can, during a playback of a test, tell TestComplete to record images of the application under test.  See https://support.smartbear.com/testcomplete/docs/testing-with/visualizer/overview.html.  You can then take the images generated during playback and utilize them to create Region checkpoints (https://support.smartbear.com/testcomplete/docs/testing-with/checkpoints/regions/about.html). 

     

    Once you have your region checkpoints added to your project, you have some option settings you can adjust.

     

    For updating baselines, you can go to Tools -> Options -> Engines -> Stores.  If you check the flag next to "Update regions", every call to Regions.Compare or Regions.Check will update the stored baseline.  If you uncheck the flag, those calls will do the comparison.

     

    Hope this helps.

    • TMUGHILENDRAN's avatar
      TMUGHILENDRAN
      Occasional Contributor

      Regions.Compare needs 2 parameter as Baseline Image and Testline Image like Regions.Check(Picture1,Picture2) 

      so how can i check with the Stored image in the Visualizer in Testcomplete and provide me a demo example so i can under that easily.

      for example :

       

      function Checkregion ()
          Object1.Click()
      end function

       

      As you can see in this code i like to store Object1 image while playback and when i run it again i want to compare with old image with real time object image.

      So can you give me a example for that.

       

      Thanks in Advance.

      • TMUGHILENDRAN's avatar
        TMUGHILENDRAN
        Occasional Contributor

         

        Hi,

        I have Enabled the flag from Tools -> Options -> Engines -> Stores "Update Regions" still its not working,

        for example :

         

        function Checkregion ()
            Object1.Click()

            Call Regions.regionsObject.Check(Object1)
        end function

         

        I have checked the flag in "Update Region" even though its still compare with old image its not updating the region. 

         

         

        Thanks in Advance.

    • TMUGHILENDRAN's avatar
      TMUGHILENDRAN
      Occasional Contributor

      Also Is it possible to store all these images to a particular location and get all these image from a given location and compare that with real time application.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        I guess the point I'm trying to make is that, yes, you can do what you're asking... but it's not an "out of the box" functionality.  For what you're asking, you're going to need to write some of your own code to save the files in order to update the baselines and then utilize those saved files in running your tests.  So, I envision a function that would look something like this:

        function imageComparison(testObject, filePath, fileName) {
            //Create a project variable called updateBaseline and make it boolean. 
            //When you want to update your baselines, set it to true
            var pictureBaseline = Utils.Picture();
            if (Project.Variables.updateBaseline) {
                testObject.Picture().SaveToFile(filePath + fileName);
            }
            else {
                pictureBaseline.LoadFromFile(filePath + fileName);
                pictureBaseline.Compare(testObject.Picture())
            }
        }

        So, instead of using the built in Regions.Compare or Regions.Check, you would use the above method.  If the project variable is set to true, your baseline files will be updated... if it's set to false, you'll do the comparison.