0

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

1
  • seems like i need override SetText function with prototype? any ideas, guys? Commented Mar 28, 2016 at 8:04

1 Answer 1

0

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");
}
Sign up to request clarification or add additional context in comments.

5 Comments

it doesn't work, I have waiting for SetValue("text") popup, and then test is failed
Do you have project example for it? // Define a custom class function customClass() { // Define a class property var classProperty; } // Define a class routine customClass.prototype.classRoutine = function() { // ... } function Test() { var obj; // Create an instance of the class obj = new customClass(); // Set the class property obj.classProperty = 41; // Call the class routine obj.classRoutine(); }
I've put a sample code that does not require ODT to the answer.
Sample, how to use the OOP approach without the ODT feature works fine in one file, but then I'm trying to use it in separate Tests it doesn't work. Can you help me? Thanks in advance, Denis
This should work fine with several units as well. Put the class code to a unit (say MyClassUnit) and include this unit to your test unit with the //USEUNIT MyClassUnit statement.Then, you will be able to use the Test routine from my example in the second unit without any changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.