Forum Discussion

megha_phophalia's avatar
megha_phophalia
Contributor
22 days ago

Verify file exists in keyword test,not showing result if true

I use if then statement in keyword test and it looks like this -

After selecting if in value 1 I took code expression and added this line :

 

And in value2 I select boolean and value as true.


So this will check if file exist is true .Then it will log message -File created .
But these steps are not working and also file is present in the given folder .Also tried with aqFileSystem.Exists(Path). Not logging message .
Is there any step I am missing 

 

2 Replies

  • nastester's avatar
    nastester
    Regular Contributor

    Not sure if this will help you much but I have a script routine that I call in a keyword test to do something similar:

    function DownloadFileExists()
    {
        var file = "C:\\Users\\" + Sys.UserName + "\\Downloads\\Text_Messaging.pdf"
        
        if (aqFileSystem.Exists(file)) {
          
            Log.Message("File exists: " + file);
        
        } else {
          
            Log.Error("File does not exist")
        }
    }