Forum Discussion

samirc23's avatar
samirc23
Contributor
12 years ago

error - 'DDT.CurrentDriver' is null or not an object (jscripting)

Hi,



while doing data driven testing i get following message. 



'DDT.CurrentDriver' is null or not an objec.




function loginfunction()


{


 DDT.CSVDriver("C:\foldername\filename.txt");


 }


 {


 DDT.CurrentDriver.DriveMethod("Unit1.search");


}




function search ()


{

UserName.keys(DDT.CurrentDriver.Value("username"));

Password.keys(DDT.CurrentDriver.Value("password"));

}



Please let me know what could be posible solution to this issue.



Many Thanks,

Sam




  • Hi Gena,




    Thank you very much for your reply, but still same error, please find below code.

     



    function loginfunction()


    {


     DDT.CSVDriver("C:\foldername\filename.txt",true);


     }


     {


     DDT.CurrentDriver.DriveMethod("Unit1.search");


    }




    function search ()


    {

    UserName.keys(DDT.CurrentDriver.Value("username"));

    Password.keys(DDT.CurrentDriver.Value("password"));

    }





  • karkadil's avatar
    karkadil
    Valued Contributor
    Once again, you are mixing the 2 DDT approaches.



    In the loginfunction you shouldn't try to access CurrentDriver property.



    You need something like this



    var mycsv = DDT.CSVDriver("C:\foldername\filename.txt");

    mycsv.DriveMethod(...)
  • Hi Gena,



    Thank you very much for your reply, but it was syntax issue, I’m from vbscript background and now trying to work on jscript.

    Many thanks,

    Sam

  • Hi Gena,



    It may sounds little funny but following script was working fine till now (scenario 1), but now it’s giving me error “'DDT.CurrentDriver' is null or not an object”. I would really appreciate if you can please let me know where I’m making mistake and send me solution to it please. In scenario 2 I have also tried same way you mentioned in your comment but having same error and funny part is that it also same sometime it works and sometime error “'DDT.CurrentDriver' is null or not an object”.



    Scenario 1)



    function loginfunction()

    {

     DDT.CSVDriver("C:\\foldername\\filename.txt");

     DDT.CurrentDriver.DriveMethod("Unit1.search");

    }

    function search ()

    {

    UserName.keys(DDT.CurrentDriver.Value("username"));

    Password.keys(DDT.CurrentDriver.Value("password"));

    }

     

    Scenario 2)



    function loginfunction()

    {

    {

    var mycsv;

     mycsv = DDT.CSVDriver("C:\\foldername\\filename.txt");

    mycsv.DriveMethod("Unit1.search");

    }

     

     

    }

    function search ()

    {

    UserName.keys(DDT.CurrentDriver.Value("username"));

    Password.keys(DDT.CurrentDriver.Value("password"));

    }

     

  • karkadil's avatar
    karkadil
    Valued Contributor
    Scenario 1 is incorrect, just forget it.



    Scenario 2 is correct, I have just tried it on my PC. My best guess right now is you have specified incorrect unit name (Unit1).



    So just check that all parameters are specified correctly (the file exists, unit name and function name are correct, etc.).
  • Hi Gena,



    Thank you very much for your reply, but in scenario 2 if it works 4 to 5 times correctly and then 6th time giving error. I know it sounds strange, but for now I ll keep 2nd scenario and let you know if it keep giving me error and if it does than may have to find work around because cannot spend lot time on only functionality :) 

  • Hi Gena,

     

    Thank you very much for your reply, but getting error 'mycsv' is undefined.