What is the difference between Test Objects and Runtime Objects in QTP? Is the given explanation correct?

◇◆丶佛笑我妖孽 提交于 2020-01-14 04:00:09

问题


On a blog about QTP, the following is stated:

"All software applications and websites are getting developed using many different components or small units (e.g textbox control in vb, input tag in HTML, webbrowser contorl in .net) which can be called as Objects.

Some of the properties can be changed during run-time. These are known as RO (Runtime object) properties. And some of them can not be changed. They are known as TO (Test Object) properties."

Is this explanation correct?


回答1:


To understand the difference between Test Objects and Runtime Objects, it helps to think outside the computer for a moment.

Imagine, if you will, that you're sitting at your desk, and you are thirsty. But you can't go to the breakroom yourself to get a drink from the soda machine. So, instead you grab an intern, give him some coins and send him to the breakroom to get you a drink.

This particular intern is very new, so you have to explain to the intern exactly what you want them to do step by step.

Your script is very simple:

1) go to "the break room".
2) go to "the machine"
2) insert coins into "the coin slot"
3) press "the Coke button".
4) bring the can back to you.

So, in your script, you have described some things.

"the break room" is the name of the room that contains the machine.
"the machine" is the name of the machine in the break room.
"the coin slot" is the name of a hole in the front of the machine.
"the Coke button" is the name of a button on the fronf of the machine.

Now, since this intern is so new, he asks you "How will I know those things when I see them?"

So, you have to describe "the break room" as "It's the last room down the hallway with the green door." you also have to describe "the machine" as "It's the Red machine with lots of buttons on the right side" you also describe "the coin slot" = "it's the long rectangular slot above all the buttons" finally, you describe "the Coke button" = "It's the big white button with a Coke logo on it".

The intern writes down all these descriptions as a list on a piece of paper. The intern now has a piece of paper with names and descriptions of things that you expect him to see when he gets to the break room.

So, next the intern actually walks to the break room...

he finds the machine ...

he finds the coin slot and puts in the coins...

he searches the controls for a big white button with a Coke logo, but he cannot find one. So, he comes back to you.

"I could not find "the Coke button" as you described it," he says. As it turns out, the buttons were recently changed, and now all the buttons have a black background. You explain this to the intern, and he changes the description on his piece of paper. You send him back to try again.

So, the intern walks back to the break room...

he finds the machine...

he finds the coin slot and puts in the coins... (the machine previously spit them back out automatically, and he got them back)

he searches the controls for a "big black button with a Coke logo on it", and he finds it, and presses it.

The machine dispenses a coke.

So, he comes back and delivers your drink to you.

Now, using the above story, it should be much easier to explain the difference between Test Objects and Runtime Objects.

The intern is your test tool - QTP.

Test Objects are just Descriptions of real objects that your test tool should look for, just the same way the intern had to search for real objects (or "things") on the machine.

The list of things on the paper that your intern wrote down is like an Object Repository. Each description has a Name and the description. The script has names, and QTP looks up those names and gets the description from the OR. As an example, your instructions to your intern could look like this:

Room("the break room").machine("the machine").slot("the coin slot").insert-coins-into
Room("the break room").machine("the machine").button("the Coke button").press

Runtime Objects are the actual objects in your AUT, just the same way that there was a real physical machine, a real physical coin slot, and a real physical button to press to get a Coke. In software testing, those objects aren't physical, but they are real.

You can programmatically read your description of an object using GetTOProperty. Also, you can change the descriptions of objects by editing your Object Repository, or you can programmatically change the on the fly using .SetTOProperty() from within your code. What this does is change the description of the object your looking for - for example, if you change the description from a Coke logo to a Sprite logo, then your intern would successfully identify the button for Sprite, and your script could work with no other changes, except that you'd end up with your intern bringing you a Sprite instead of a Coke.

While you can change the descriptions, you can't change the actual real objects any more than your intern can change the coke button from black to white. However - once your intern FINDS the button - he can interact with the button by pressing it, looking at it, jiggling it, or smelling it. He just can't change it to something else. There is no SetROproperty method for objects, but you can GetROProperty, meaning once the button has been identified by it's size, color and logo, you can also ask your intern to tell you how wide it is, or if it has an "out of stock" indicator you can ask the intern to tell you if that light is on or not.

Hopefully this fully answers your question about the difference between Test Objects and Realtime Objects in QTP.




回答2:


Some of the properties can be changed during run-time

Above statement is not correct.

Test Objects are the objects that are stored during recording.

Run-Time objects are the objects that is displaying in your AUT while playback your script.



来源:https://stackoverflow.com/questions/11512875/what-is-the-difference-between-test-objects-and-runtime-objects-in-qtp-is-the-g

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!