fbpx

Using wildcards in validation

Using wildcards in validation

Home Forums Ask Expert Using wildcards in validation

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #31636
    Ken Hopper
    Participant

      I am trying to determine if wildcards can be used in text validation? For example, I have a file that is created daily with the same name but the date added at the end of the filename each time it is run. I would like to be able to validate that the file exists but the test will fail if the filename changes due to the date in the filename changing each time I run it.

      Thanks!

      #31637
      Sasha ZAP
      Moderator

        Hello kenh,

        You definitely can use a wildcard in ZAPTEST:
        To use a wildcard you add the file name as an object and specify its “Text” property as, for example, “Test_2.*”, ZAPTEST will then locate the file which has the prefix “Test_2”.

        But based on your description I believe the best solution is not to use a wildcard because, for example, if there are several of such files with the same prefix in the same directory ZAPTEST may located a different file instead of the specific one;
        In such case (Where there is a chance to have several of such files) I would recommend to generate the file’s name, for example, if the file’s name is “Test_2162018.xls” use this code to generate the file’s name, update the “Text” property and check if the file exists:

        strDate = Date
        strDate = Replace(strDate, “/”, “”)
        strFilename = “Test_” & strDate & “.xls”
        Application(“Application”).View(“View”).Object(“File Name”).SetProperty “Text”, strFilename
        If Application(“Application”).View(“View”).Object(“File Name”).Exist Then
        Application(“Application”).CustomReport True, “File Exists”, “File exists.”, True
        Else
        Application(“Application”).CustomReport False, “File does not Exist”, “File does not exist.”, True
        End If

        Hope this helps.

        Thanks,
        ZAPTEST Team

      Viewing 2 posts - 1 through 2 (of 2 total)
      • You must be logged in to reply to this topic.

      Virtual Expert

      ZAPTEST

      ZAPTEST Logo