Forum Discussion

kylegogtp's avatar
kylegogtp
Contributor
5 years ago

Start next step only after batch file is complete

I am looking for a way (without using delays) to only start the next step in the test only if the previous step batch file has completed.

  • BenoitB's avatar
    BenoitB
    Community Hero

    Quick ideas without delays

    - Use errorlevel of batch file

    - Use a file as a marker of batch finished

     

     

    • hkim5's avatar
      hkim5
      Staff

      as BenoitB says above, you need a marker of whatever process to indicate that the batch file has finished.

      so whatever you are doing with the batchfile, I'm assuming there is a clear indicator of whatever process to have ran (or do whatever its supposed to do)

      Then you can use the name mapping objects and their properties to find that same property, and provide it the conditional logic so that the next step continues on only after that one property is met. just a quick idea

      • sonya_m's avatar
        sonya_m
        SmartBear Alumni (Retired)

        Thank you everyone!

         

        kylegogtp was this helpful? Let us know🙂

    • kylegogtp's avatar
      kylegogtp
      Contributor

      Using a batch to create a file to mark it. But what would be the best way to have Testcomplete wait to check the existence of the file? The batch time to run can be variable especially on different computer builds, so I will need it to check continuously until file is there.

       

      I found this script that might work. I cannot use absolute paths because the folder location of source control can vary for machines as well.

       

      function FileExistsExample()
      {
        var sPath;
        sPath = "c:\\MyFile.txt";
        
        if (! aqFileSystem["Exists"](sPath))
          aqFile["Create"](sPath);
        aqFile["WriteToTextFile"](sPath, "Hello, world!" + "\r\n", aqFile["ctANSI"], false);
      }