Difference between Class Name and Class in QTP

Updated On Mar 25, 2014 by Ankur Jain

When you spy on an any object in QTP, it shows two different properties Class Name and class. Ever wondered what is the difference between the two?

classname_vs_class

Let me show this with the help of an example -

Shown below is a simple HTML button.

When you use Object Spy on this button, Class Name will be WebButton while class will be shown as buttons.

Class Name is the basic essence of that object. If Class Name gets changed the object itself would get changed. Hence, an object of type button will always be shown as WebButton under Class Name, a hyperlink would always be shown as Link, a browser object would always be shown as Browser and so on. A point to note here is that, while object spy shows the property as Class Name, the same property should be written as micclass while using Descriptive Programming.  For ex:

Browser(“micclass:=Browser”).Page(“micclass:=Page”).WebButton(“micclass:=WebButton”,”PropertyName:=PropertyValue”).Click

class is a selector used for styling purposes in HTML. This property can take any user defined name as defined by the developer of your application. In this example, we have defined

<input class="buttons" type="submit" />

If we change that to

<input class="UserDefinedButtons" type="submit" />

the spy will now show the class as UserDefinedButtons while Class Name will still be shown as WebButton

I hope the above explanation has answered all your questions around Class Name, class and micclass in QTP.

If you’re into automating web applications, I recommend you to get good knowledge on HTML and CSS. Learning to write HTML/CSS won’t take much time but will help you a long way in your job as an automation tester. In case of any issue, you will be able to think like a developer and that thing alone would help you to resolve those little issues that come up every now-and-then during automation. There are various free and paid courses available on the internet. My recommendation is to try HTML/CSS courses at TeamTreeHouse, I have personally gone through some of their courses and can whole-heartedly recommend them.

If you have any questions, please feel free to ask in the comments section below.

Welcome new readers: Download the Free eBook!

Ankur JainI am Ankur Jain, the owner of LearnQTP and founder of a software organization. This site is run, maintained and updated by me and my team. Feel free to take a look around, you may want to start with What is QTP? 

You can connect with me on my Google+ page. 

Please enter your first name and email address below to instantly download the eBook on Optimizing QTP Scripts. In future, we will make sure you get new tips & tricks on QTP delivered direct to your email box.



Share This Article:

12 Comments

  1. Rajan

    Nice explanation. Even QTP beginner also can easily understand this concept..

  2. حجز فنادق

    great
    i love your blog a lot.

  3. Rajesh

    Hi,

    How to get complete grip over QTP vb scripting.What should I do?

  4. suresh

    what is the difference between class and object?

  5. Md Asif Eqbal

    Thanks Ankur for sharing such a basic thing.

  6. Dipanwita

    In descriptive programming, is classname a mandetory properly to mention for an object?

    • Ankur Jain

      @Dipanwita: You use those properties which can uniquely identify an object. Normally you use the properties that QTP takes as part of ‘learned description’.

  7. Senthil

    Thanks Ankur. This would clarify for many fresher in QTP.

  8. dhiraj

    Very informative.. Thanks..

  9. Thatavarthi Srini

    What is the difference between micclass and class name

    • Ankur Jain

      As mentioned above, Class Name seen in object spy is written as micclass in Descriptive Programming. mic probably stands for ‘Mercury Interactive Component’.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>