Forum Discussion

mkirkland's avatar
mkirkland
Contributor
14 years ago

Copy data to a variable

I am new to TC and also dont know much about coding but i am trying to figure out if there is a way to store an object property to a variable that i can call later on in the test. I have read some other forum threads about similar issues but it has all been done with java cade or soemthing similar. Is there any other way to save web data to a variable to call back later in the test/project?

5 Replies

  • ttran's avatar
    ttran
    Occasional Contributor
    if you are using VB, then read on.

    I ran into the same issue when I learned testcomplete. What I noticed is: there're 2 different types of data

    1. variables, strings, etc... You can store them by

    X = "Data"

    2. Object coming from Testcomplete Object Browser.... You can store them by

    set X = Sys.Process("iexplore", 2).Page("http://www.google.com").subtree.moresubtree
  • My scripts will be in either JScript or c#. Maybe leaning more towards JScript but im looking to create a variable based on an object property within one of my keyword tests. The above links have helped and im looking through some help menu items. Im new to scripting so its a slow start.



    So do i have to write a script to run a Keyword Test and then save the output of the test to a variable within the script (string, boolean, integer). Once i have that vaiable i can continue the script with if...then to perform other actions based on the output that was saved into the variable?
  • Hi,



    Generally speaking, scripts and KD tests are not related to each other. They're just different ways of programming the same actions. You don't have to make scripts communicate with KD tests and vice versa, but you can do this if it is needed in your case. So, the answer is "it depends on what you want to do". You can access the same data in both scripts and KDT, and you can mix them and pass data between them if you need.
  • Ok, so i figured it out. I first used the innerText[Get] and then next used the Set Variable Value statement using the Last Operation Result value. Then later on in the test i called that Set Variable Value that was defined earlier. Sweet.