Forum Discussion

sohailalam2696's avatar
sohailalam2696
Occasional Contributor
6 months ago
Solved

Undefined folder created

It creates an undefined folder only. Inside Undefined we got Manual and inside Manual we got time stamp. The main problem is the first folder Undefined. Could anyone please help me?

 

 

function Test()
{

var currentDateAndTime = aqDateTime.Now();
var currentTime = aqDateTime.Time();
var currentDate = aqDateTime.Today();




var projectName = ProjectSuite.Variables.projectName;
var testtype = ProjectSuite.Variables.testtype;
var timestamp = aqDateTime.Now(); //currentDate + currentTime;
if(testtype == "Manual")
{
ProjectSuite.Variables.buildnumber = aqConvert.DateTimeToFormatStr(timestamp, "%m%d%Y_%H%M%S");
}

var folderPath = "E:\\Results\\" + projectName + "\\" + testtype +"\\" + ProjectSuite.Variables.buildnumber + "\\";


//var folderPath = Project.Variables.resultpath;

// Check if the folder already exists
//if (!aqFileSystem.Exists(folderPath)) {
// Create the folder
//if (aqFileSystem.CreateFolder(folderPath)) {
// Log.Message("Folder created successfully: " + folderPath);
// } else {
//Log.Error("Failed to create folder: " + folderPath);
// }
//} else {
// Log.Warning("Folder already exists: " + folderPath);
//}

aqFileSystem.CreateFolder(folderPath);

//folderPath = folderPath + "\\"
Log.SaveResultsAs(folderPath, lsXML, true, 1); // Files are created in the Project1 folder
}

  • Folder is created without issues,

    Ensure you have appropriate permissions to create a folder in your E: drive.

5 Replies

  • MW_Didata's avatar
    MW_Didata
    Regular Contributor

    let me understand this a little better, The resulting folder should be :

    "E\Results\'YourProject'\Manual\'YourBuildNum'\'File'"

     

    And the actual result is :

    "E\Results\Undefined\Manual\'YourBuildNum'\'File'"

     

    If so, sounds to me the variable "ProjectSuite.Variables.projectName" does not exist

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Folder is created without issues,

    Ensure you have appropriate permissions to create a folder in your E: drive.

    • sohailalam2696's avatar
      sohailalam2696
      Occasional Contributor

      Will it create folder all the time? Cuz I do not want to create folder all the time, just one folder and then timestamp added to it.

      Thank you

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Will it create a folder all the time - if you were to run the script multiple times, what do you think? Use aqFileSystem.Exists method before creating the folder.

     

    Also check all your variables, by debugging your code to ensure it has the appropriate values that you expect.