April 26, 2013

How to create a keyword test in TestComplete (from SmartBear Software)?

TestComplete is a test automation tool that can test a variety of applications like Windows applications, web applications, web services, Adobe AIR applications and Java applications. Tests can be created as either Keyword tests or Scripts. The former are more suitable for beginners in test automation and the latter are more suitable for people who know a scripting language like VBScript or JScript and who have written test automation. It is very simple to build a keyword test in TestComplete. In this post, let us see how to build a keyword test in a browser based application quickly.

First, you open TestComplete on your Windows machine. Create a new project using the File > New > New Project... menu item. A wizard starts. Specify the Tested Application Type as Functional testing of web pages. Select the scripting language as VBScript or JScript. Select Finish. You should have a new project open as shown below.


Click the Record Keyword Test button (red button in the top toolbar). TestComplete should minimize to a small floating toolbar with a few buttons (Record, Stop, Pause and Create new checkpoint). Open Internet Explorer on your machine. In the address box, type the URL, http://www.google.com and press the Enter key. In the Google search box, type Software Testing Space and press the Enter key. You should get the search results. In the TestComplete toolbar, click the Stop button to stop recording. TestComplete should stop and generate the keyword test similar to the one shown below.


Close Internet Explorer. If you find any unnecessary steps in the test (for example using Windows Explorer to launch Internet Explorer), just right click on that step and click Delete. In order to run the test that you created, click the Run Test button. TestComplete should open Internet Explorer, navigate to Google and search Software Testing Space. TestComplete shows a log similar to the one shown below.


Now, let us enhance this existing test. In TestComplete, click the Append to Test button. It should ask you where you want to append more test steps. Select To End. Switch to the open Internet Explorer window. We want to verify that the search results show a link for Software Testing Space. In the TestComplete floating toolbar, click the down arrow next to the Create new checkpoint button. Select Create Property Checkpoint. This opens the Create Property Checkpoint wizard. Now, we need to select the object (the Software Testing Space link in the Google search results) whose property we want to verify. Drag the cross hair icon on to the Software Testing Space link. TestComplete puts a red border on the selected object. Release the mouse button once the correct link is selected (shown below).


Click the next button. We need to verify that the innerText property of this link is Software Testing Space. Click the Advanced view link in the wizard. Now, either scroll to the innerText property or find it using the Search box. Make sure that the innerText property is Software Testing Space.

 Click the Finish button in the wizard. Click the Stop recording button in the TestComplete floating toolbar. Your test should be similar to the one shown below. It should have one more test step containing the Property Checkpoint. If you find any unnecessary steps in the test (for example for switching to Internet Explorer), just right click on that step and click Delete.

 Now, the keyword test is complete. Close Internet Explorer. Click the Run Test button to launch your new test. You should get a test log similar to the one shown below.
As you can see, it is very simple to create a keyword test in TestComplete. Try to create more tests. There are many other operations and checkpoints that you can use in your tests. Let me know if you have any question on building keyword tests. Until next time.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.