0

Here is what I am trying to do:

I have 25 queries to run that are in a separate file. They are all named by what they are returning. So if I want to loop through them, can I just use a variable to call each query I want to return?

    var _Q = QueryFile;

    var part1 = generalName;  //Amount
    var part2 = aqString.Replace(Object1.wSelectedItems, " ", "");  //Due
    var part3 = aqString.Replace(Object2.wText, " ", "");  //LessThan

    var allParts = part1+part2+part3;  //AmountDueLessThan

    var query = _Q.queryName();  //query = AmountDueLessThan()

    Log.Message(query);

part1 never changes, part2 changes every five iterations, and part three changes every iteration. I'm trying to write a function to execute this piece so that it works for all 25 queries.

Is there a way to format the queryName string to call the query from QueryFile?

Thank you,

Dan

1 Answer 1

0

I am not sure what is QueryFile in your case.

In general, there are two ways to do this in TestComplete using JScript/JavaScript.

  1. If the separate files are added to your project as script units, you can use the Runner.CallMethod routine:

    var _Q = "MyFile";
    var fName = "AmountDueLessThan";
    Runner.CallMethod(_Q + "." + fName);
    
  2. Use the eval function.

    var fName = "AmountDueLessThan";
    eval(fName + "()");
    
Sign up to request clarification or add additional context in comments.

2 Comments

The eval function worked perfectly! Thank you so much!
@Dan, great! So, you can accept my answer as a solution. ;)

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.