Forum Discussion

danza3000's avatar
danza3000
New Contributor
7 years ago
Solved

DDT.CurrentDriver' is null or not an object

i keep getting this error on my testing using javascript. I have looked all materials within smart bear...not sure what else to do. 

 

This is what i have so far.

 

function DriveMyTest()
{

var mycsv;

mycsv = DDT.CSVDriver("C:\\TestComplete\Book1.csv");
mycsv.DriveMethod("ScriptTest.Test1");

 

}

 

function Test1()
{

textbox = panel.textboxClaimLabOrderId;
textbox.Click(72, 1);
textbox.SetText(DDT.CurrentDriver.Value("textboxClaimLabOrderId"));

 

}

  • Hoping this is not a typo in your post... but you have a problem in your code.

    Since you're using JavaScript, you need to make sure you use the double-backslash for all slashes in your file path.

     

    so... change this:

    mycsv = DDT.CSVDriver("C:\\TestComplete\Book1.csv");

    to this

     

    mycsv = DDT.CSVDriver("C:\\TestComplete\\Book1.csv");

    and try again.  CurrentDriver will be "null" if the CSVDriver method failed to return a driver... which it would if the file path is incorrect.

5 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Hoping this is not a typo in your post... but you have a problem in your code.

    Since you're using JavaScript, you need to make sure you use the double-backslash for all slashes in your file path.

     

    so... change this:

    mycsv = DDT.CSVDriver("C:\\TestComplete\Book1.csv");

    to this

     

    mycsv = DDT.CSVDriver("C:\\TestComplete\\Book1.csv");

    and try again.  CurrentDriver will be "null" if the CSVDriver method failed to return a driver... which it would if the file path is incorrect.

    • danza3000's avatar
      danza3000
      New Contributor

      Another strange thing happening with testcomplete is that the same test, after i made the changes you suggested on the file path, it worked once, by writing the first 2 text field and than failed. I am unable to run pass the same error message again. Question is, why did it worked once? am i missing anything?

      It kind of work when i change the variable name....mycsv. Any suggestion on how to approach this?

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        danza3000 wrote:

        Another strange thing happening with testcomplete is that the same test, after i made the changes you suggested on the file path, it worked once, by writing the first 2 text field and than failed. I am unable to run pass the same error message again. Question is, why did it worked once? am i missing anything?

        It kind of work when i change the variable name....mycsv. Any suggestion on how to approach this?

         


        I don't see that you're missing anything in your code.  When you say it failed, what happens?  What errors do you get?  Is there some behavior in your application under test that you're not seeing?

  • danza3000's avatar
    danza3000
    New Contributor

    Thank you for your input, i tried that as well, and still get the same error. DDT.CurrentDriver is null.