WORKING WITH QTP

TestEveryThinG

Archive for February, 2011

Running Automation Scripts on a Remote Computer

Posted by rajivkumarnandvani on February 19, 2011

 

Running Automation Scripts on a Remote Computer

By default, when you create an Application object in your automation script, it is created on your local computer (using your local copy of QuickTest Professional). You also have the option to run automation scripts on a remote QuickTest computer. To do so, you must:

     

  • Ensure that the Distributed COM (DCOM) Configuration Properties of the remote computer are set to allow you to run QuickTest Professional Automation from your computer.
  • Specify the remote computer in the automation script in the application creation script line, for example, using the optional location argument in the VBScript CreateObject function.

Setting DCOM Configuration Properties on the Remote Computer

QuickTest automation enables QuickTest to act as a COM automation server. Therefore, to run a QuickTest automation script on a remote computer, you must ensure that the DCOM configuration properties for that computer give you the proper permissions to launch and configure the QuickTest COM server.

The procedure below describes the steps you need to perform on the remote computer to enable your automation script to run on that computer. Note that the DCOM Configuration Property the appearance and names of the dialog boxes and options mentioned here may vary depending on the computer’s operating system.

To enable automation scripts to access a QuickTest computer remotely:

     

  1. On the computer where you want to run the automation script, choose Start > Run. The Run dialog box opens.
  2. Enter dcomcnfg and click OK. The Distributed COM Configuration Properties dialog box or the Component Services window opens (depending on your operating system) and displays the list of COM applications available on the computer.
  3. Select QuickTest Professional Automation from the list and open the Properties dialog box for the application. (Click the Properties button or right-click and choose Properties, depending on your operating system.)
  4. In the QuickTest Professional Automation Properties dialog box, click the Security tab.
  5. In the launch permissions section, choose the custom option and click Edit.
  6. Use the Add and Remove options to select the network users or groups for which you want to allow or deny permission to launch QuickTest Professional via an automation script. When you are finished, click OK to save your settings.
  7. Repeat steps 5 and 6 for the configuration permissions section to select the users or groups who can modify QuickTest Professional configuration options via an automation script.
  8. In the QuickTest Professional Automation Properties dialog box, click the Identity tab and select the interactive user option.
  9. Click OK to save the QuickTest Professional Automation Properties settings.
  10. Click OK to close the Distributed COM Configuration Properties dialog box or the Component Services window.

Creating an Application Object on a Remote Computer

Once you have set the necessary DCOM Configuration settings for a remote computer, you can specify that computer in your automation script.

In VBScript, you do this by specifying the computer name as the optional location argument of the CreateObject function. The computer name should be the same as the computer name portion of a share name. For example, to run an automation script on a computer called MyServer, you could write:

Dim qtApp

Set qtApp = CreateObject(“QuickTest.Application”, “MyServer”)

For information on the syntax for specifying the remote computer in another language you are using, refer to the documentation included with your development environment or to general documentation for the programming language.

Posted in QTP | 4 Comments »

Get cell data from webtable

Posted by rajivkumarnandvani on February 16, 2011

Hi all ,

I found a helpful example in QTP help file that can be use most of time while working with web table. I hope It will help you.

Description

Returns the text contained in the specified cell.

Syntax

object.GetCellData (Row, Column)

Argument Description
object A test object of type WebTable.
Row Required. A Variant value. The row number where the cell is located. The first row in the table is numbered 1.
Column Required. A Variant value. The column number where the cell is located. The first column in the table is numbered 1.

Return Value

A String value.  Returns the data contained in the specified cell.
If the specified cell is not valid, the method returns micCellDoesNotExist

Find All Employees That Live in the Same City
Sub GetCellData_GetRowWithCellText_Example()
‘The following example retrieves the names of all employees that live in
‘the same city as John Smith so that he can arrange rides home with them.
‘First, the example finds the table row containing
‘”John Smith”. Then it checks the value of the CityColumnn cell to determine
‘the city in which John lives. It searches the table cells to find all other
’employees that live in that city. Finally it uses the GetCellData method to
‘return those employees names and, using a function, generates a list
‘containing those names.

CityColumn = 4
NameColumn = 2
‘Get the row number for employee ‘John Smith’
RowNumber = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).GetRowWithCellText(“John Smith”)
Set AccommodationsCity = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).ChildItem(RowNumber, CityColumn, “WebEdit”, 0)
TableRows = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).RowCount
‘Search for all employees that live in the same city as ‘John Smith’ and add them to his ride home list
For i = 1 To TableRows
Set CurrentCity = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).ChildItem(i, CityColumn, “WebEdit”, 0)
If CurrentCity.GetROProperty(“value”) = AccommodationsCity.GetROProperty(“value”) Then
EmployeeName = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).GetCellData(i, NameColumn)
AddToJohnSmithRideHomeList (EmployeeName)
End If

Next

End Sub

Posted in QTP | 7 Comments »