samirc23
11 years agoContributor
Can I call already created DDT driver from one unit to other units?
I have created DDT function in unit3 and I would like to use it in unit1, unit2 and etc, is it possible and how?
I tried it following way, but it’s not working.
Unit3:
function abcfunction1()
{
{
var mycsv;
mycsv = DDT.CSVDriver("C:\\path\\file.txt");
mycsv.DriveMethod("Unit3.Unit1");
mycsv.DriveMethod("Unit3.Unit2");
}
}
In unit1 and unit2 I added ‘add unit references’ of unit3.
Unit1:
function test()
{
Object. SetText(DDT.CurrentDriver.Value("yourname"));
}
Unit2:
function xyztest()
{
Object. SetText(DDT.CurrentDriver.Value("name"));
}
Please let me know how to use already created DDT function in other units.
I tried it following way, but it’s not working.
Unit3:
function abcfunction1()
{
{
var mycsv;
mycsv = DDT.CSVDriver("C:\\path\\file.txt");
mycsv.DriveMethod("Unit3.Unit1");
mycsv.DriveMethod("Unit3.Unit2");
}
}
In unit1 and unit2 I added ‘add unit references’ of unit3.
Unit1:
function test()
{
Object. SetText(DDT.CurrentDriver.Value("yourname"));
}
Unit2:
function xyztest()
{
Object. SetText(DDT.CurrentDriver.Value("name"));
}
Please let me know how to use already created DDT function in other units.
- Well, of course you get an error, since inside the abcfunction1 function you declare a new one (local) variable, which is destroyed after the function exits.
But this question isn't related to TestComplete or JScript, this is a common programming question, any developer could answer it. I suggest you to start learning basics of procedure programming (global and local variables, functions, passing parameters by value and reference), otherwise you will have to ask a lot of questions and get all of them answered in so much details.
For instance, I will not spend time teaching anyone basic programming concepts, sorry. There are many tutorials and books dedicated to this.
Testing automation requires understanding programming, that's where you should start from.