Skip to main content

HP QTP Tutorial Chapter 8

1 Automation

In my previous chapter, I discussed about the features available in Insert Menu, QTP Checkpoints and usage of Output Value features. This chapter covers the features available under Automation Menu option. This chapter explains the following features available under Automation Menu:
clip_image002[4]

The features under Automation are very frequently used when you need to do the scripting. You can control your recording, run your test, and update your Test. We will cover most of the features in detail in this chapter.

 1.1 Record

Recording features work in 2 ways. One when you are starting a new test and want to start recording for generating the Test Script and when you want to enhance existing script for new features in your AUT. I will explain both the mode. We will start with Record for New Test. When you are starting with New Test, and about to start with recording of your scenario, you have to either press F3 or navigate to Automation=>Record. As soon as you have initiated either of these commands, you will see a Record and Run Settings Dialog (I will discuss about Record and Run Settings in Chapter 9). As of now you need to know basic things which I am explaining below:
clip_image004[4]
Based on your need, you have to provide the settings for your recording so that AUT script can be generated as you navigate or explore your AUT. You are seeing 2 Tabs – Web and Windows which are default. You might see other Tabs if you have different application such as SAP, Siebel, PeopleSoft etc. Based on your need, you have to choose either of the options. For our sake, we will choose “Record and Run test on any open browser”. But before that we will ensure we do not have any other browser opened with other application or website. When we choose this option we are going to open only the application under test. After your settings, you need to click OK. As soon as you click OK, you are into recording mode and whatever action you are performing on AUT, all these actions are getting logged or recorded. You can see the script or steps generated automatically in Keyword or Expert View. Another important point is that of Analog Recording and Low Level Recording which only get enabled when you start your recording. I will discuss these 2 additional types of recording in later part of this chapter. If your “Capture Screen Images while Recording” is enabled, then you can also see the recorded screen shot in Active Screen section. At any point of time, press F4 to stop the recording.

 1.2 Run

As part of scripting and to do unit test and debugging, you need to run your script. You can do so by opening the Test Script and then either press F5 or navigate to Automation=>Run. When you press F5, you see a Run Dialog box having 2 tabs – Result Location and Input Parameters (More detail will be covered in Chapter 9). As of now let the Result location set as Temporary without making any changes. After you click OK, your test execution will get started and you can either Pause your test- press PAUSE key or stop by pressing F4. Once your test completes, you can see the Test result after execution.
clip_image006[4]

 1.3 Stop

As the name suggests, whenever you want to completely stop your test execution, you can press F4 or navigate to Automation=>Stop. Please remember this option is enabled only when your Test is in execution mode. You can also press F4 when your AUT is taking too much time to respond.

 1.4 Run Current Action

You might come up with cases, while you are doing debugging of the script where in you just need to run a particular action in your Test Script. I am considering that you are having more than 1 action in your script. What to do in such a scenario? Well, QTP have solution to this, you need to select the action which you want to execute and then click Automation=>Run Current Action. This will execute the current action only but if current action have further reusable nested actions, then those will also get executed as part of run. But you always have option to PAUSE or STOP – F4.

1.5 Run from Step

When you are writing your script, there might be certain situation where you want your script to be executed from a particular line of code. In such cases you need to place cursor on that line and choose Run from Step. You can also right click on that line, and choose Run from Step. The shortcut key is Ctr+F5. I will say, that this is also very frequent command which you will be using when you are developing your script, debugging your script or enhancing your script. This command will ignore all the script above the line from where you have initiated the Run from Step. For e.g. See below:
clip_image008[4]
If I have to run the code from line 4, I should place my cursor on line 4 and then either Press Ctr+F5 or Rt Click=>Click Run from Step or Goto Automation=>Run from Step.

Note: When you have loop or conditional statement in your code, and you are trying to run from line which is inside loop or conditional statement, then your script will return error related to syntax, so please pay attention while executing your code from specific line and ensure that cursor is placed at right place in case of loop and conditional statement.

 1.6 Analog & Low Level Recording

Analog Recording and Low Level Recording are workaround options when normal recording fails to solve am automation business problem. For e.g. If you are working on Legacy Application and HP QTP does not recognize the action being performed, or you are dealing with BITMAP application, in such scenario, you can choose to record your test in Analog or Low Level Recording mode. I will explain the difference between these 2 in below paragraph.
Analog recording is needed when I am having a scenario where I need to digitally draw my signature for future reference or I need to draw unique image as passcode. Whenever operation which can be accomplished by using mouse movement and we want to capture the exact movement of mouse, then we will enable Analog Recording mode. You can only enable analog recording when you are already in normal recording mode. You need to Press Shift+Alt+F3 or goto Automation=>Analog Recording. As soon as you execute the command you get switched into Analog Recording Mode.

 1.7 Record and Run Settings

You can access the Record and Run Settings from Automation->Record and Run Settings. The usage of Record and Run Settings is explained below:
clip_image010[4]
Depending on the Add-Ins available you can see the Tab. For e.g. If you have Siebel Add-Ins or SAP Add-Ins, you can see the respective tab on this window. The tab allows you to provide the necessary settings for script recording and execution. We will explain the Web and Windows Tab.
Web Tab
Record and run Test on any open browser” - When you choose this option, QTP record the script on any open browser (Internet Explorer). As a best practice, you will select this option when you are doing the scripting for Web Based Application. Normally in real time, you record your test script by opening the AUT and framework is going to launch your AUT and perform the necessary actions as per Test Script.
Open the following address when a record or run session begins” – When you want to launch specific URL you can select this option. You can also set the default browser which will get launched when you start your recording or about to execute the Test Script. In real time we hardly use the second option. This is mostly used when people are learning the QTP Tool. The other 2 checkboxes – “Do not record and run on browsers that are already open” will ensure that actions are not getting recorded on other browser apart from the one which is launched while recording and “Close the browser when the test closeswill ensure that the AUT browser will get closed when you close the Test. Again these 2 options are hardly used in real time Test Automation.
Windows Tab
clip_image012[4]
In Windows Tab you can see following options to control your recording and execution on Windows Based Application.
Record and run Test on any Window-based application” - When you choose this option, QTP record the script on any open Window application which is supported by native OS (VB Application, MS Word, Notepad, Calculator etc). As a best practice, you will select this option when you are doing the scripting of Window Based Application. Normally in real time, you record your test script by opening the AUT and framework is going to launch your AUT and perform the necessary actions as per Test Script.
Record and run only on” – Under this checkbox you have other option to control your recoding and execution. You can specify the conditions such as “Record and Run Only On – Application opened by Quick Test”, “Record and Run Only On – Application opened by via the Desktop(by the Windows shell)”, “Record and Run Only On – Application Specified below – You will specify the application exe path in the grid section by navigating to the application exe path.” In real time we do not use the other options for Script Recording and Execution.

 1.8 Results

In case you are not able to view the results after test execution or later you want to see the result of last execution, you should navigate to Automation->Results. QTP will show the Result of the last Test execution. See the below Open Run Result Window which ask for Result path when you try to open the Result without opening any test or without executing the test.
clip_image014[4]
You can either open the Test using Test name and selecting the Run name or if you know the XML result file path, you can use Results XML File option to view the result.
If your test is opened and you want to view the result, click Automation->Results. It will display the last run results.

 2 References

Quick Test Professional Tool.

 3 Additional Information

You can email me on Sachin.vasudha@gmail.com with any query.

 4 What Next?

In my next Chapter I will explain the Resources Menu and the usage of various features such as Object Repository, Object Repository Manager, Associate Repositories, Map Repository Parameters, and Associated Function Libraries.

Comments

Popular posts from this blog

Is AI taking over your job in software development and testing? 😱"

Are you a software developer or tester feeling threatened by the rise of AI in your industry? 😰 You're not alone. Many professionals in the field are concerned about the potential consequences of AI's integration into software development and testing. While some experts believe that AI can bring significant benefits to the industry, others worry that it could replace human expertise altogether. 🤔 AI algorithms can analyze massive amounts of data and automate many tasks, but they cannot replace the critical thinking and creativity of human beings. Additionally, there are ethical concerns associated with the use of AI in software development and testing. So, what can you do to ensure that you're not replaced by AI in your job? 💪 First, it's essential to recognize that AI is not a replacement for human expertise but rather a tool to augment it. Therefore, it's essential to learn how to work with AI-powered systems to increase your efficiency and productivity. Additi

Revolutionize software testing with AI! 🤖💻 Share your thoughts on ethical implications in the comments.

  As technology evolves, so too does the field of software testing. One exciting development in recent years is the use of AI (Artificial Intelligence) to automate repetitive tasks and improve testing accuracy. Through analyzing large amounts of data and identifying patterns, AI can help identify potential defects or vulnerabilities in software. AI-powered tools can also generate test cases and scenarios by simulating user behavior and input, allowing for more efficient and effective testing. In addition, machine learning algorithms can analyze and learn from past testing data, leading to better predictions and more streamlined testing. AI-powered tools can also help identify and prioritize critical bugs and defects, saving valuable time and effort in manual testing. But it's important to note that AI-powered testing is not a replacement for human testers. While AI can automate certain tasks and help identify potential issues, it's still necessary for human testers to provide a

HP Quality Center - Best Practices

1.Introduction Quality Center is a test management tool which provides very good features for managing both your manual and automated test cases. This paper highlights the best practices for managing your test cases. When you open Quality center, depending on your rights it display the below mentioned option in the sidebar: 1. Requirements 2. Test Plan 3. Test Lab 4. Defects 5. Dashboard 2.Requirements When you have assigned with the responsibility of developing your test cases in the quality center then you must be wondering where to start with. I am going to share my experience to overcome such a situation. You need to find the solution of some question before you start writing your test cases. 1. Is your requirement developed and available? 2. Is your requirement organized in a logical sequence? If answer to both of the above question is Yes, then you can start with Requirement option in the side bar. In case your requirement is under development, then you keep your