check if folder exists

Hi, i am fairly new to eggplant and sensetalk , can anyone please help me in the below

how to check if a specific folder exists

Comments

  • sds2usersds2user Member
    If you are checking to see if a folder exists on the sut then you will need to write a .bat script that is ran via eggplant on the sut.

    If you are checking to see if a folder exists on the machine driving the sut, this is how I do it. 
    The below example stores the path in a variable,
    Checks to see if the folder exists,
    If it is found it deletes it
    then creates a new folder

    set rundir to "/some/path"
    if there is a folder rundir then
        Delete folder rundir
    end if
    create a new folder rundir

    More info can be found here: http://docs.testplant.com/ePF/SenseTalk/stk-file-folder-interaction.htm


    Hope that helps!
  • rovorovo Member

    Hi,

    Your request is from the kind of “available & reuseable standard functionalities by avoiding to invent the wheel again and again…”. The key solution approach is: outsource encapsulated functions (like AWS micro-service approach) in libraries. This lead to the flexible way, that many library functions, can be used by several (master) scripts (one master script can “call” many libraries or helper files). So library functions must be developed only once, but can be reused n-times. We can provide already 200+ available “standard libraries functions to manage standard actions in the scripts”, one of them is specially for checking if files or folders are copied correctly to a specific path on the SUT.

    Here is a small excerpt from one of our library functions.

    Snippet of copying a videofile:

    ---

    "CMD/Control".RunCMD

     log "The movie to be played = "&global testFilename

     set fileCopied to "Files/Control".copyFile(global settings's testdataShare,global testFilename, global documentsFolder)

    if not fileCopied then

        Log "Copying the file did not seem to work. Using the alternative Share."

        set fileCopied to "Files/Control".copyFile(global settings's testdataShareAlternative, global testFilename, global documentsFolder)

    end if

    "CMD/Control".CloseCMD

    if not fileCopied then

        LogError "Could not verify that the video was copied. The test will be stopped."

        throw "KIG_FileNotCopiedException", "Could not verify that the video was copied. The test will be stopped."

    end if

    ---

    If you want to share further information, sent a short DM.

    Regards,
    Robin

Sign In or Register to comment.