Forum Discussion

mcretacci's avatar
mcretacci
New Contributor
2 years ago

Testing with text files

Hi,

i was wondering if anyone has tried testing with log files. im creating a test that looks over text files and put a parameter if the logfile is less than or greater than the value put. this is the code i have so far but it keeps giving me an error with the script im making. Any thoughts or ideas on how i can make this happen?

 

import sys
import os
import aq
def read_text_file_and_test(file_path):
   try:
       with open(file_path, 'r') as file:
if __name__ == "__main__":
   if len(sys.argv) != 2:
       print("Usage: python test_script.py <path_to_text_file>")
       sys.exit(1)
   text_file_path = sys.argv[1]
   if not os.path.isfile(text_file_path):
       print("The provided file does not exist.")
       sys.exit(1)
   read_text_file_and_test(text_file_path)

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    In TestComplete, you can also count the time it takes to load the application.

     

    What is the content of the text file? What is the time format?

     

    See Reading Text Files

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    How do you test with log files? Log files are usually referred to test results when automation is completed.

     

    I don't understand what your code is supposed to do?

     

    "if the logfile is less than or greater than the value put" - what does this mean?

    • mcretacci's avatar
      mcretacci
      New Contributor

      i created a powershell script to log the time it takes to load the applications. for example: when user logs in, the biostime came out to be 15.756 seconds in the logged txt file. in testcomplete, i want the test to read the number in the file and create an if/else statement like: if bioslog is greater than 3 seconds fail, if less than pass.