Forum Discussion

maheshwari_a's avatar
maheshwari_a
New Contributor
12 years ago
Solved

XML Checkpoint

Before the create the xml Checkpoint , i have to perform some actions in the system for the xml file to be generated.once the file is created i will start creating the xml checkpoint where in the source i will specify the path of the file.

My xml file name format is something simillar to 4444_2012-10-03_12-22-19.xml i.e 4444_date_Time.xml(date and time comes from when file was created),once this test is created.

When i start running the test, test goes and does some system actions, again another xml will be generated but on this file the time will vary. For eg now the File name is 4444_2012-10-03_12-32-20.xml .

So if the file name is changed ,checkpoint will fail and will log message-Error: The system cannot locate the object specified.

So how can I test this above scenario.Please Help.

  • Hi Maheshwari,


     


    There are a few approaches that you can use:


    1. If there is only one XML file in the folder where you store your XML files, you can use the aqFileSystem.FindFiles method to get the file and pass it to the Check method for comparison:


    var foundFiles, aFile;


      foundFiles = aqFileSystem.FindFiles("C:\\Work\\", "4444_*.xml");


      if (foundFiles == null)


        return;


      aFile = foundFiles(0);


      XML.XMLCheckpoint1.Check(aFile);




    2. If there are many XML files in the folder, you can get the last modified file. For this, you need to check the result of the GetLastWriteTime method.


     

1 Reply

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Maheshwari,


     


    There are a few approaches that you can use:


    1. If there is only one XML file in the folder where you store your XML files, you can use the aqFileSystem.FindFiles method to get the file and pass it to the Check method for comparison:


    var foundFiles, aFile;


      foundFiles = aqFileSystem.FindFiles("C:\\Work\\", "4444_*.xml");


      if (foundFiles == null)


        return;


      aFile = foundFiles(0);


      XML.XMLCheckpoint1.Check(aFile);




    2. If there are many XML files in the folder, you can get the last modified file. For this, you need to check the result of the GetLastWriteTime method.