Forum Discussion

e_lock's avatar
e_lock
Occasional Contributor
12 years ago

Refreshing datasource

Hi all,  I have a test which I am trying to make work which runs through a number of iterations.  On each iteration I wish to use a different datasource.  I do this by replacing the spreadsheet with a different one of the same name in the same location.  The only problem is that TestComplete seems to be retaining a handle on the original spreadsheet which is preventing me from deleting it.  I am trying to call the script using jscript.  The first iteration (where we don't yet have a handle to the spreadsheet) works fine, second iteration fails.  The error messsaage is "Permission denied"  Any ideas?  Thanks in advance,  Ellie (apologies for the poor formatting, this field isn't recognising my return key).

9 Replies

  • e_lock's avatar
    e_lock
    Occasional Contributor
    fso = new ActiveXObject("Scripting.FileSystemObject");    fso.DeleteFile(fileLocation);
  • simon_glet's avatar
    simon_glet
    Regular Contributor
    Hi Ellie,



    Do you release the file with CloseDriver ?



    function testSomething(fullPathExcelFileName

    {

      var excelWorksheetData = DDT.ExcelDriver(fullPathExcelFileName, worksheetName);



      // test loop



      DDT
    .CloseDriver(excelWorksheetData.Name);



      // Delete fullPathExcelFileName here

    }



    Sincerely


  • e_lock's avatar
    e_lock
    Occasional Contributor
    Thanks for the reply.  The problem is I get a handle to the data source via the gui, not actually in the code.
  • simon_glet's avatar
    simon_glet
    Regular Contributor
    Hmm, confused here ...



    How can TestComplete keep a handle on the file it is not opening ? Are you using project variables of type "DB Table" ?



    Sincerely
  • e_lock's avatar
    e_lock
    Occasional Contributor
    It is opening it, I'm just not doing that in my script - I'm doing it via the gui.  So I don't already have a handle to it; I just wasn't sure whether there would be any conflict.  I'll try it out now and check (didn't have any time to go back to it yesterday).
  • e_lock's avatar
    e_lock
    Occasional Contributor
    THis is very frustrating, I have now tried all sorts of ways to release the handle on this file and to no avail.  I have tried doing as suggested by the previous poster, doing a disconnect via a project variable, playing about with the permissions on the folder etc etc.  I am at a complete loss - please someone help!!!  I have a demo this afternoon, and really need it to work for that!
  • paul_scroce's avatar
    paul_scroce
    Frequent Contributor
    Did you open the file using GUI of the application under test or are you using TestComplete DDT?



    If you opened the file using GUI of your application then see if you can delete it after closing the application.
  • e_lock's avatar
    e_lock
    Occasional Contributor
    No, I get a handle to it via smart bear ddt. So far as I can see it didn't open at all, otherwise I could just kill the process using script.
  • e_lock's avatar
    e_lock
    Occasional Contributor
    Found the answer!!  At last!!  I have extracted the nested data driven loop into another keyword test, and once that has completed it's loops I call a scripted function which does a disconnect on a KeywordTests Variable (I was originally trying to call it against a project variable which it didn't like.  Phew!  So pleased it works.