I have ODT.Class Actions with code
function SetValue(text){
HowToGetObject? .Keys(text + "[Enter]")
}
And ODT.Data.CustomerName element it has type of Actions class, so I can use SetValue method Also it has method GetObject, that allow me to get object:
function GetObject(){
return NameMapping.Sys.Orders.OrderForm.Group.Customer
}
The bellow code works with system SetText() method
ODT.Data.CustomerNameTextField.GetObject().SetText("Text")
I need somehow get object reference in my SetValue(text) method in order to do bellow
ODT.Data.CustomerNameTextField.GetObject().SetValue("Text")
I'm interested in system SetText(string) method? How does it work?
Will be glad to have any help. Thanks in advance, Denis
The easiest way is to get the object right within the SetValue method:
function SetValue(text){
This.GetObject().Keys(text + "[Enter]")
}
The standard SetText method can be applied to editors that can have a textual value and just puts the text to these editor programmatically.
BTW, as far as I know, the ODT functionality is going to be completely removed from TestComplete soon. See Object-Driven Testing for details. Here is a sample demonstrating how to use the OOP approach without the ODT feature:
function customClass(newObjName)
{
this.objName = newObjName;
}
customClass.prototype.getObject = function()
{
return eval(this.objName);
}
customClass.prototype.setValue = function(text)
{
this.getObject().Keys(text + "[Enter]");
}
function Test()
{
var obj = new customClass('Sys.Process("notepad").Window("Notepad").Window("Edit")');
obj.setValue("Test");
}