QTP – Parameterization with Local DataTable

Parameterization is a process in which parameters, or variables are substituted for hard-coded values which help perform the same operations on the AUT with multiple sets of data. In other words, in QTP, parameterization helps automation developers test an application with different data from a single action (or multiple actions) through multiple iterations. Because the data changes each iteration, it must be stored in a data-pool, or in multiple variables. This data-pool can be QTP’s (Local or Global) DataTables, an Excel Spreadsheet (external to QTP), Access DB, SQL Server, or any database of your choice. It can also come from several Environment variables. This topic will describe parameterization with QTP’s DataTable.

The trick to successful parameterization is cycling around a process. For example, consider a flight booking/checkout process. You would first login to the application, find and select the flight of your choice, make the purchase, and in the end view the confirmation.

If you were to parameterize the above process, instead of ending your script at the confirmation page, you would end it at the Find Flight page. This is because, when the next iteration executes, it is already at the correct page which can enable the script to start all over again at the expected point. In other words, our process should look like below:

Parameterization with DataTable

Before we start with the actual parameterization, we must first understand how data will be retrieved from the DataTable and the settings that we need to make in order to cover all the rows. In our example, we will test a few UserName and Passwords in the HP/Mercury’s Demo AUT.

Below, I have created 2 columns in the Local (Action1) DataTable- UserName & Password. You can create columns by simply double-clicking the Column heading:

Create Columns in DataTable

Create Columns in DataTable

Next, I will create 4 rows with different sets of data:

Add Data to Columns

Add Data to Columns

Below is the syntax to retrieve data from the DataTable’s local sheet:

'If retrieving data from Local DataTable (Action1, Action2,.. ActionN)
DataTable("ColumnName", dtLocalSheet)
 
'If retrieving data from Global DataTable (dtGlobalSheet)
DataTable("ColumnName", dtGlobalSheet)

Therefore, we can now create 2 statements using the syntax above to retrieve our user name and password:

DataTable("UserName", dtLocalSheet)
DataTable("Password", dtLocalSheet)

Before we create our script, we must first tell QTP to run the test from all rows in the Local DataTable. In Keyword view, right-click Action1 then click Action Call Properties:

Right-Click Action1

Right-Click Action1

In the Run Tab of Action Call Properties window, select “Run on all rows”. A Dialog will popup mentioning what we discussed in the beginning of this post, about ending our iteration where the first step in our process begins.

Action Call Properties Window

Action Call Properties Window

Close the dialog, then click OK to save the settings we made under Action Call Properties. We are now ready to create our script which will take data from each row and test each UserName/Password combination. Below will be the steps in our process:

1. Launch application 
2. Enter UserName/Password from DataTable and click Login
3. Verify if the Find Flights page appears
4. If Find Flights page appears, iteration passed.
5. Return to Home Page and start Step #2
'Step 1
If DataTable.LocalSheet.GetCurrentRow = 1 Then
        SystemUtil.Run "iexplore.exe", "http://newtours.demoaut.com"
End If

After executing the above code, or manually launching the application, execute the below steps:

'Parameterization Block:
With Browser("title:=Welcome: Mercury Tours", "index:=0")
	'Step 2
        'Parameter 1: UserName
	.WebEdit("name:=userName").Set Datatable("UserName", dtLocalSheet)
        'Parameter 2: Password
	.WebEdit("name:=password").Set Datatable("Password", dtLocalSheet)
	.Image("name:=login").Click
End With	
 
'Step 3
'If Find a Flight page appears, go back to Home
If Browser("title:=Find a Flight: Mercury Tours:", "index:=0").Exist(10) Then
	'Step 4
	Reporter.ReportEvent micPass, "Iteration " & DataTable.LocalSheet.GetCurrentRow, _
		"UserName: " & Datatable("UserName", dtLocalSheet) & " is valid"
	Browser("title:=Find a Flight: Mercury Tours:", "index:=0").Link("text:=Home").Click
Else
        'Step 5
        'Else, fail the iteration and return to the Home page
	Reporter.ReportEvent micFail, "Iteration " & DataTable.LocalSheet.GetCurrentRow, _
		"UserName: " & Datatable("UserName", dtLocalSheet) & " is invalid"
	Browser("title:=Sign-on: Mercury Tours", "index:=0").Link("text:=Home").Click
End If

Once the above script ends its execution, your test results should look like this:

Execution Results

Execution Results

This topic covered a very high-level process of parameterization, but I hope it gives you a good idea how this process can be enhanced and adapted to your application. The next topic in Parameterization will cover Excel Spreadsheets and a few tricks that we can use for successfully driving different sets of data to our AUT.

Subscribe for Relevant Codes newsletter to get awesome updates and articles delivered straight to your inbox.

Leave a Comment

{ 127 comments… add one }

  • sowmya January 22, 2014, 4:50 am

    i am unable to execute script with all the inputs

    Reply
  • Yogesh January 13, 2014, 1:15 am

    Hi,

    I am new to QTP. I found your post very helpful to understand Data driven Testing.
    But i have One question. Please provide answer.
    I have to automate a web application. which has below steps.
    1. Open a Url
    2. Enter Login Name and password.
    3. Click on specific page(a Link).
    4. On that page we have to enter Emp. Name, Email Id and Phone.
    5. Click on Ok button.

    Now i have to automate the steps 3, 4 and 5 stpes with different data values.
    I dont want to repeate the 1st and 2nd step. how to do that. plase give me a code for this(Loop condition).

    Reply
  • Imran Khan December 26, 2013, 7:00 am

    hi,

    Just one query i have in regards to the data table usage with excel. Once i have loaded an excel data table (local) to QTP and the automation starts, the automation runs perfectly fine. HOwever in the end when i open the data table in excel QTP has created headers for the empty columns with just the Header Letter which was in excel. Any idea why does this happen?

    Reply
  • pooja March 20, 2013, 4:34 am

    Hi

    I am learning QTP so it will help me in reading your relevant codes.

    Thanks
    Pooja

    Reply
  • Rose February 21, 2013, 5:52 am

    Hi,

    I am writing in datatable and exporting it.So whenever I write and export, excel size is increasing. I Have to iterate it for 500 times and that time if file size is big the performance will be reducued or some other issues may occur. How can we overcome this excel size problem.

    Reply
  • June January 15, 2013, 4:44 am

    Script incomplete

    Reply
  • Pedro Perosin November 28, 2012, 12:43 pm

    When I import some spreadsheets into a test, run them, and then export the spreadsheet, it gets expanded to like 65k+ rows.

    This is making QTP crash. Can you help me?

    Reply
  • raveendra kumar July 27, 2012, 1:40 pm

    It is very help to me,and also it’s very easy to understand

    Reply
  • Anshika Goyal July 10, 2012, 4:27 am

    there is 1 web element “eleReport_Name”

    i have to paramaterize its text using below code

    Browser(“brOracleBIInteractive”).Page(“pgOracleBIInteractive”).WebElement(“eleReport_Name”).SetTOProperty “innertext”, DataTable(“in_HeaderName”, dtLocalSheet)

    then i want to check if the web element eleReport_Name exists or not….

    so i am using below if statement

    If Browser(“brOracleBIInteractive”).Page(“pgOracleBIInteractive”).WebElement(“eleReport_Name”).Exist(5) Then

    but it is picking value which is hard coded..not from data table…wht to do fr it?

    Reply
    • Anshoo Arora July 10, 2012, 10:31 am

      Anshika, try this:

      If Browser("brOracleBIInteractive").Page("pgOracleBIInteractive")
          _.WebElement(DataTable.Value("ColName", dtLocalSheet)).Exist(5) 
      

      ColName is the target column in the Local DataTable.

  • Madhumita May 28, 2012, 9:59 am

    Hi Anshoo,

    I have a query regarding dataTable. I have only one action and there are around 65 different sheet in the excel which includes diferent flows. At runtime based on the testcase I want to add those sheet and execute..can I do it? If so can you please give me a code..

    Reply
  • Anonymous April 24, 2012, 6:39 am

    Hi,

    How to read one xml fiel and put the contents of it( whole contents as it is) in to a table field in database usign QTP?
    The table looks like below. Need to put the xml file contents(from top to bottom) in to field XML_DATA(data type is CLOB).

    CREATE TABLE FAST_USER.FS_AIB_TRANSACTIONS
    (
    ID NUMBER(6) NOT NULL,
    AIB_REF_NO VARCHAR2(30 BYTE),
    PIP_REF_NO VARCHAR2(30 BYTE),
    TR_CODE CHAR(10 BYTE) NOT NULL,
    STATUS_ID NUMBER(3) NOT NULL,
    CREATED_DATE DATE NOT NULL,
    XML_DATA CLOB
    )

    Reply
  • Kiran Chikkala April 16, 2012, 6:39 am

    Nice Article

    Reply
  • Rachel Wang January 11, 2012, 7:25 pm

    I am seeking for a help …

    My test comprises 5 re-usable actions, I can only run 9 rows of records (9 iterations of action run) from a DataTable of 100 rows at one time.
    I have to run the test multiple times with the set of different 9 row data each time, until complete all 100 rows.

    How can I fulfill my teask with DataTable and/or Parameterizing?

    Thanks for help!

    Reply
    • Anshoo Arora January 12, 2012, 11:52 am

      Rachel, How can you have 9 rows of records in a DataTable of 100 rows?

      How many rows in Action DataTable? How many rows in Global DataTable?

    • Rachel Wang January 13, 2012, 1:48 am

      I have 100 records, inside an action I can only setup/validate 9 records (9 iterations) at one time by limitation of application.
      My test was designed as below -

      1. Action_Login
      2. Action_SetUp (9 records)
      3. Action_Logout
      4. Action_Login (again)
      5. Action_validate (9 records)
      *** 1 iteration done *** and will repeat Action 2 ~5

      I will need to run the test multiple times to test all of 100 records.
      I could not figure out how to control the number of iterations with DataTable(Global and Action), I do not have a Global sheet, only Action table with 100 rows.

      I’ve tried to use an external file (excel sheet) instead of DataTable for inputer parameter, and it seems work for me.

      Do you think I can control my test with DataTable (Global/Action)? Theoretically I should, but I have no enough knowledge on DataTable control, please provide advice.

      Thanks.
      Rachel

  • roveena January 11, 2012, 4:41 am

    how to create and use the data pools using QTP

    Reply
  • wasay January 5, 2012, 6:36 am

    Hi,
    Can any one tell me how to insert a value in the data table of a particular position?

    Reply
  • Anu Chavan December 22, 2011, 1:36 am

    Hi Anshoo,
    Articals and problem solved by u are very good .I am facing one problem in qtp 9.2.0 with Extjs.In my test site gird is displaying with checkbox in first column to select row.now my problem is when checkbox is checked i have to get either row number or text appread in 2nd column in grid so that i will use that info for next recording.qtp is recognising that grid as webelement

    waiting for reply…

    Reply
  • Ajit December 1, 2011, 11:00 am

    Hi Anshoo,
    i need to select the checkBox of the first selected item in the DataGrid, how can i do this.

    Thanks in Advance
    - Ajit

    Reply
  • Anand Ganesan November 23, 2011, 4:04 pm

    Hi, I am new to this website. I am learning now QTP.
    I am currently working on Banking domain.
    Can you please help me in generating sequential Account numbers in VB script.

    For example : First time when I run the code, it should diplay account number as WEB000 (This number i have adden in Global sheet), Next time when it runs, it should automatically check for duplicate and create a new one like WEB001.

    Note : I can’t give all values in datatable. Please suggest

    Reply
  • Lucky November 17, 2011, 2:01 pm

    Can someone help me write a logic to clear all the previous data in the Flex Text Area.i am new to QTP scripting.

    tried this one but it didn’t worked
    private Sub ClearText
    Dim ctl as Controls
    For Each ctl in controls
    if TypeOf ctl is textArea then ctl.txt = “”
    Next
    EndIf

    Reply
  • Reddy November 1, 2011, 3:35 pm

    Any Help would be great help
    After importing two excel sheets into QTP local data tables how to compare those two sheets(Actual and Expected). Like row vs row Once compared and did not match need to put them into another sheet. Need to put both the columns from the two rows which did not match. LIke column 4 in row 1 in sheet one vs column 4 in row 1 in sheet 2. Need to color code on sheet 1 and sheet 2.

    Thanks
    Reddy

    Reply
  • prachi October 19, 2011, 12:07 am

    Hi Anshoo,

    I have a set of scripts that are stored in QC and are to be run from QC. Input data is imported from sheet placed in QC->Resources and then output(results)shuld be exported to the QC,same sheet .

    Right now,as I am just checking the scripts execution(not a final run) , I am running these scripts from QTP (not from QC).
    The problem is that data is imported from the sheet in QC but results are not exported to the same sheet .Could ypu please explain me the reason and suggest the solution.

    Below are the lines of code being used from import and export from QC:

    DataTable.ImportSheet “[QualityCenter\Resources] Resources\Test Data\Performance\Ktmy_DataSheet”,DatabaseName,DatabaseName (WORKING)

    DataTable.ExportSheet “[QualityCenter\Resources] Resources\Test Data\Performance\Ktmy_DataSheet” ,DatabaseName
    (NOT Working)

    Reply
  • vasu October 18, 2011, 2:34 pm

    I am new for this site and also to started to learning QTP so please recomend for me how to start

    Reply
  • Varun Kumar Kohli October 11, 2011, 11:56 am

    I have tried to insert value in DataTable from variable but it’s not working. Following is the used script. Please let me know the solution if you know.

    Dim res
    res = 4
    msgbox res
    DataTable.Values(“RequestID”,”Global”) = res

    here, RequestID is column name and Global is worksheet name.

    Reply
  • Anthony Mattson September 30, 2011, 7:40 am

    Can anyone help me parameterize the following script. I’m trying to run a similar SQL statement for multiple tables and I’d like to replace the name of the table for each run. I cant seem to get it to work … any suggestions

    Option Explicit
    Dim con,rs, query
    Set con=createobject(“adodb.connection”)
    Set rs=createobject(“adodb.recordset”)
    con.open”driver=sqloledb.1;Data Source=dbsw8221;Initial Catalog=UHPD_Reporting;Trusted_Connection=yes”
    rs.open”select count(*) from pd.wrkflw_mpin”,con
    Msgbox rs(0)

    Reply
    • Anshoo Arora October 11, 2011, 4:41 pm

      Anthony: You can load the table names or queries in the DataTable and as the test runs and actions loop, you will have a new value each time..

  • Jbel September 28, 2011, 2:06 pm

    Hello,
    I need to have a uniqe name for ptfirst_name every run I make. How do I make this work?

    Browser(“VectraView – Login”).Page(“VectraView – Order Tests_2″).WebEdit(“ctl00$ctl00$MainContent$MainCo_3″).Click
    Browser(“VectraView – Login”).Page(“VectraView – Order Tests_2″).WebEdit(“ctl00$ctl00$MainContent$MainCo_3″).Set DataTable(“ptfirst_name”,dtGlobalSheet)

    Thank you,
    jb

    Reply
    • Anshoo Arora September 29, 2011, 9:52 pm

      Jbel, you can use DataTable.LocalSheet.SetCurrentRow(RowNumber) to move the current row to the desired row.. If you have multiple rows of data in your DataTable, then this approach should work well for you.

  • Sachin August 23, 2011, 9:14 pm

    I want to use the output from one keyword as a input to other keyword calculation. How can this be achieved?

    Reply
  • Meena June 10, 2011, 5:24 pm

    Hi All,
    I am new to this forum and trying to learn QTP.
    I have to work on 1 exercise, if anyone can help me.

    Write a script to create 3 new orders and update some data in each order after the order creation.
    – Login Only once for each agent ( Total 2 agents )
    – Create Order and Update Order ( 3 Orders ) – Update any data that can be editable
    – Logout/Exit Once

    ( Features you can use: Data Table, Output value param, Checkpoint, Synchronization, Reusable Actions )

    Reply
    • Meena June 10, 2011, 5:26 pm

      ALso this is in respect to’Sample Flight’ Application.

      Please guide..

    • Anshoo Arora June 24, 2011, 11:02 am

      Meena: You can create 3 actions for this test:

      1. Login (runs one time)
      2. Create and Update Order (runs 3 times)
      3. Logout (runs one time)

      The way #2 above will run for 3 iterations is that, its Local Datatable will have data for 3 rows. From “Action Call Properties”, you will have to configure your execution to “Run on all rows”.

  • Kalam May 3, 2011, 4:13 am

    Anshu u r suprb
    no wrds 2 thnk u
    no wrds 2 dscrbe ur hlp
    b hapy alwys
    b wid us lik dis 4evr

    Reply
  • Elton Goudinho April 9, 2011, 3:13 am

    Could you write a qtp data table with parameters;
    Transaction type:

    Reply
  • lavanya April 7, 2011, 10:25 pm

    hi anshoo,

    i have imported excel file which has a column of 3 rows into local datatable and added a parameter to datatable. Now, if i retrieve the row count, it returns 65536 rows instead of 3 rows. Can u please tell me the reason

    datatable.AddSheet “Sheet1″
    Call datatable.ImportSheet(“E:\lavanya QTP practice\td.xls”, “Sheet1″, “Sheet1″)
    datatable.getsheet(“Sheet1″).addparameter “Res”, “”
    numrows=datatable.getsheet(“Sheet1″).getrowcount

    Reply
  • lavanya April 6, 2011, 5:04 am

    hi anshoo,

    i have imported excel file which has a column of 3 rows into local datatable and added a parameter to datatable. Now, if i retrieve the row count, it returns 65536 rows instead of 3 rows. Can u please tell me the reason

    datatable.AddSheet “Sheet1″
    Call datatable.ImportSheet(“E:\lavanya QTP practice\td.xls”, “Sheet1″, “Sheet1″)
    datatable.getsheet(“Sheet1″).addparameter “Res”, “”
    numrows=datatable.getsheet(“Sheet1″).getrowcount

    Reply
  • Sakthi January 6, 2011, 12:52 am

    Hi,
    While running the below script i got an error message as ” Object doesn’t support this property or method: ‘Echo’ “.

    Set WshShell = CreateObject(“WScript.Shell”)
    Set WScript = CreateObject(“WScript.Shell”)

    Code1 = WshShell.Popup(“Do you feel alright?”, 7, “Answer This Question:”, 4 + 32)
    Code2 = WScript.Popup(“Learn from new things”, 10, “Answer:”, 1 + 48)

    Select Case code1
    case 6 WshShell.Echo “Glad to hear you feel alright.”
    case 7 WshShell.Echo “Hope you’re feeling better soon.”
    case -1 WshShell.Echo “Is there anybody out there?”
    End Select

    Select Case Code2
    case 1 WScript.Echo “Yes”
    case 2 WScript.Echo “No”
    case -1 WScript.Echo “Nothing”
    End Select

    Please help me to resolve the above error.

    Thanks
    Sakthi

    Reply
    • Anshoo Arora January 10, 2011, 7:36 am

      Sakthi,

      Use WScript.Popup instead of WScript.Echo.

    • Anonymous January 10, 2011, 7:59 am

      Thanks..

      Its working fine.. But why it is showing error when we use ‘Echo’?

    • Anshoo Arora January 10, 2011, 3:04 pm

      Echo is not one of the supported commands for WScript when invoked from QTP..

  • Surya January 5, 2011, 10:31 am

    Hi

    Is it possible to use checkpoints for every iterations. For Example, after one iteration i need to check Green tick or Red Cross adjacent to the text box. Green tick to be displayed for valid values

    Thanks
    Surya

    Reply
    • Anshoo Arora January 10, 2011, 7:33 am

      Surya: Yes. You can use CheckPoints whenever necessary.

    • Surya January 17, 2011, 7:01 am

      thanks Anshoo, it worked

      In my application Green tick is displayed adjacent to a text box for valid values. My aim is to create a checkpoint for Green tick. It works in recordand playback.However I am unable to create correct property value(Descriptive programming) for Green tick as it is developed in CSS Style sheet. can you please suggest what property value i can give so that QTP identifies. Gui Spy identifies the field as web element. please find the property details below.Thanks
      Property Name
      ——————-
      abs_x
      abs_y
      class
      height
      html id
      html tag
      innerhtml
      innertext
      outerhtml
      outertext
      visible
      width
      x
      y
      Type

    • Varun Kumar Kohli October 11, 2011, 10:33 am

      I have tried to insert value in DataTable from variable but it’s not working. Following is the used script. Please let me know the solution if you know.

      Dim res
      res = 4
      msgbox res
      DataTable.Values(“RequestID”,”Global”)

      here, RequestID is column name and Global is worksheet name.

    • Shelley Wang December 28, 2011, 10:45 pm

      You may try:
      Dim res
      res = 4
      msgbox res
      DataTable.Values(“RequestID”,”Global”) = res

      I’ve tried it, it works well. But you must make sure you’ve already created a column named “RequestID” in run-time “Global” sheet.

      Hope it works for you too.

  • Prasad October 21, 2010, 4:45 am

    Thanks a lot….Really have a nice web site to learn QTP

    Reply
  • Sakthi October 15, 2010, 7:44 am

    Hi,

    Anyone can explain the difference between Wait Property and wait Item property.
    with suitable example.

    Thanks
    Sakthi

    Reply
  • SAkthi October 15, 2010, 7:42 am

    Hi,
    Any one can Given some detailed example for descriptive scripts using Datatable

    Thanks
    Sakthi

    Reply
  • Deepak August 7, 2010, 9:08 am

    Hi Anshoo,

    I have one more question.
    My company want to me to design a KEYWORD driven framework. I am pretty much aware of designing ‘Hybrid Framework’. Currently i am using ‘Modularity’ in the Hybrid Farmework.

    Could you please guide me, what all required to start designing Keyword framework. Please give me some idea, so based on that i can ask you few question.

    Reply
  • Deepak August 2, 2010, 1:48 pm

    Hi Anshoo,

    I went through all your posts and comments. All these are quite elaborate. I may ask you some irritating questions, please answer me those with example.

    What is Action parameters, datatable parameters, How it is useful in Parameterization. Could you please provide your answer with examples.

    Thanks
    Deepak

    Reply
    • Anshoo Arora August 5, 2010, 1:58 pm

      Deepak,

      Each of the topics in your question can span across multiple pages. I would suggest you to read Parameters from the QTP reference. I am still in the process of finalizing a few articles, and once that is done, I will work on an article based on parameters. I’m sorry, but that’s all the advise I can offer right now :(

    • Anonymous August 7, 2010, 8:43 am

      Hi Anshoo,

      Thank you for the reply. I do accept your advise. I read it from the QTP reference, for me its not clear. If you are going to prepare few articles on ‘Parameterization’ then please do inform me. I feel, your document will be great help for me.

      Thanks
      Deepak

  • Gayathri June 15, 2010, 6:07 am

    Hi Anshoo ,

    My query is : I have data in 3 columns in my Global sheet , first row contains TC (which contains numbers like 1, 2…) and second column contains functions fn1,fn2… and 3rd column contains some data .

    Now i have to extract data from sheet and when TC=1 execute fn1, when tc =2 execute fn2 and soon .

    can u help me on this

    thanks
    Gayathri

    Reply
    • Anshoo Arora June 22, 2010, 12:18 pm

      Gayathri,

      Most of this can be done through conditional statements. For example, you can use the Execute statement to execute a keyword within QTP:

      If DataTable("TC", dtLocalSheet) <> "" Then
          Execute DataTable("Function", dtLocalSheet)
      End If
      

      More on Execute here: http://relevantcodes.com/eval-function-execute-statement/

      Similarly, you can extend the above approach and add another statement where the data will also be written to your application. I hope this helps. If you have any questions, please feel free to post them here :)

  • Chandrakala June 1, 2010, 1:58 pm

    I’m facing an issue with drop down value change in Weblist.

    For a drop down, earlier the application used to have 1) blank value 2) Apple 3) Banana 4) Cookie and 5) Dessert
    Then there was a slight change made to the order and value in the drop down:
    1) blank value 2) Apple 3) Banana 4) Cookie and 5) Dairy

    The datatable is set to select the value ‘Banana’.

    While running the script and msboxing the value from the datatable, it reads ‘Dessert’ – Script fails as there is no such value.
    If I run the script only from that step, msgboxing the value from the datatable reads ‘Banana’ which is the desired value.

    Any idea on what could cause this issue. Any suggestions are most appreciated.

    Chandrakala
    Cleveland, USA

    Reply
    • Anshoo Arora June 7, 2010, 8:43 am

      Not sure why you’re seeing this behavior. If your script is written to select ‘Banana’, I don’t see why it would select any other value unless you’re doing it through a custom function. Can you post your function or your script here?

  • raja May 29, 2010, 12:40 am

    Hi Anshoo,

    I have one doubt on Actions and their corresponding local data sheets. As we always specifies as each action will have one local data sheet with it. In books or articles i have read as local data sheet data available to corresponding action only (Ex: Action1 local data sheet data available for Action1 only ). But we can able to access Action1 local data sheet data in Action2. Can you please clarify me on this?

    Reply
    • raja June 7, 2010, 11:11 pm

      Can you please answer my above question?

    • Anshoo Arora June 8, 2010, 7:36 am

      Hi Raja,

      You can retrieve the data of Action2 from Action1. Suppose you have a column named ColA in Action2 and you would like to retrieve its value in Action1. You can use the following code in Action1 to do so:

      DataTable.GetSheet(3).SetCurrentRow 1
      MsgBox DataTable.Value("ColA", 3)
      
    • Raja June 9, 2010, 1:40 am

      Hi Anshoo,

      Thanks for the reply.. So we can able to access one local data table value in any action.

      Thanks,
      Rajasekhar

  • Vishal Jhaveri May 13, 2010, 7:46 am

    Hi Anshoo,
    Thanks for your prompt reply, i tried using your method however i want to iterate through the Local datatable…Lets say there are 2 rows in the local datatable.. So i want to iterate through the first row collect the data, append timestamp to it and write it into the Global datatable. So during first iteration i collect the values from the local datatable add the timestamp and write it on the first row of the Global datatable. then i iterate through the second row do the same procedure and write the values in the 2nd row of the Global datatable.
    I tried using this method:

    DateTimeStamp()
    UniqueValue1= Environment.Value("TimeStamp")
    RowCount = DataTable.GetSheet("Local").GetRowCount
    i = 1
    For i = 1 to RowCount 
    DataTable.LocalSheet.SetCurrentRow(i)
    sEmailAddress = DataTable.LocalSheet.GetParameter("EmailAddress").Value
    sEmailAddress = DataTable.GlobalSheet.AddParameter("EmailAddress_freelancer", ""&sEmailAddress ).Name
    sUserName = DataTable.LocalSheet.GetParameter("Username").Value +""&UniqueValue1
    sUserName = DataTable.GlobalSheet.AddParameter("Username_freelancer", ""&sUserName ).Name 
    sPassword  = DataTable.LocalSheet.GetParameter("Password").Value
    sPassword = DataTable.GlobalSheet.AddParameter("Password_freelancer", ""&sPassword ).Name
    sTenancy =  DataTable.LocalSheet.GetParameter("Tenancy").Value +""&UniqueValue1
    sTenancy = DataTable.GlobalSheet.AddParameter("Tenancy_freelancer", ""&sTenancy ).Name
    Next
    

    However in the Global sheet all the values are written in the same row..
    Can you please suggest a way to do it…
    Thanks,
    Vishal

    Reply
    • Anshoo Arora May 14, 2010, 9:46 am

      You can increment the row of the Global Sheet the same way its done for the Local Sheet:

      DataTable.GlobalSheet.SetCurrentRow(i)
      
  • Anu May 11, 2010, 1:17 am

    Hi…………
    I need to write the data from the web page to the excel. I was able to write but my problem is when i go to the next link of the same web page,then it writes the data to the excel but overwrites the previuos data.
    Please tell me the solution for that so that i can write the data into excel.
    Thanks in advance………………..

    Reply
    • Anshoo Arora May 12, 2010, 10:08 am

      Anu,

      Where would you like to write the new data to Excel? In a new worksheet, or in a new row/column of the same worksheet?

    • Anonymous May 13, 2010, 3:54 am

      Hi Anshoo,

      I want to add data in a new row/column of the same worksheet so that it
      do not overwrite the previous data present in the same worksheet.
      Thanks for yours previous response.

      Regards,
      Anu

    • Anshoo Arora May 14, 2010, 9:42 am

      Anu,

      To store data to a new Excel column each time, we can retrieve the number of Used Columns in that particular Excel sheet, and append to the unused columns. That means, for each new iteration, you would need to retrieve the new column to which the data will be written to:

      Set xlApp = CreateObject("Excel.Application")
      Set xlBook = xlApp.WorkBooks.Open("C:\Test.xls")
      Set xlSheet = xlBook.WorkSheets("Sheet1")
      
      'Code that will retrieve the new column:
      iNewColumn = xlSheet.UsedRange.Columns.Count + 1
      
      xlBook.Close
      xlApp.Quit
      
      Set xlSheet = Nothing
      Set xlBook = Nothing
      Set xlApp = Nothing
      
    • Anu May 17, 2010, 5:16 am

      Hi Anshoo,
      Below is the code where i used the code given by you.
      It is just overwriting the previous data.

      Dim xlSheet,xlBook, xlApp,a,CustomerName,Address,datatable
      Const ForAppending = 8
      const TristateTrue=-1
      file_location = “F:\Test.xls”
      ‘———-’For Wirting in Excel Sheet’

      Set xlApp = CreateObject(“Excel.Application”)
      Set xlBook = xlApp.WorkBooks.Open(“F:\Test.xls”)
      Set xlSheet = xlBook.WorkSheets(“Sheet1″)

      CountOfRows=Browser(“Meghalaya Directory Search”).Page(“Meghalaya Directory Search_3″).WebTable(“DataTable”).WebTable(“Table”).RowCount
      For i = 1 To CountOfRows-1
      CustomerName=Browser(“Meghalaya Directory Search”).Page(“Meghalaya Directory Search_3″).WebTable(“DataTable”).WebTable(“Table”).GetCellData(i,3)
      Address=Browser(“Meghalaya Directory Search”).Page(“Meghalaya Directory Search_3″).WebTable(“DataTable”).WebTable(“Table”).GetCellData(i,4)
      xlSheet.Rows(i).Columns(1).Value =CustomerName
      xlSheet.Rows(i).Columns(2).Value =Address
      iNewcolumn=xlSheet.UsedRange.Columns.Count + 1
      Next
      ‘xlBook.Save
      ‘xlBook.Close
      ‘xlApp.Quit
      Browser(“Meghalaya Directory Search”).Page(“Meghalaya Directory Search_3″).WebTable(“LinkTable”).Link(“2″).Click

      NOTE: For every link there is a datatable whose data i have fetch and write on to the excel.

      The code given by you is not working from my side so please tell the correct way or if have done any mistake in the above mentioned code
      then please let me know.

      Thanks,

    • Anu May 18, 2010, 12:13 am

      Hi Anshoo,

      Could you please reply my query………….
      As my deadline is very nearby.
      Hope u can understand.

      Thanks In Advance.

      Regards,
      Anu

    • Anshoo Arora May 18, 2010, 8:09 am

      You will also have to increment the columns as they’re used as static values:

      Dim xlSheet,xlBook, xlApp,a,CustomerName,Address,datatable
      Const ForAppending = 8
      const TristateTrue=-1
      file_location = "F:\Test.xls"
      Dim iCol : iCol = 0
      
      '———-’For Wirting in Excel Sheet’
      Set xlApp = CreateObject("Excel.Application")
      Set xlBook = xlApp.WorkBooks.Open("F:\Test.xls")
      Set xlSheet = xlBook.WorkSheets("Sheet1")
      
      CountOfRows=Browser("Meghalaya Directory Search").Page("Meghalaya Directory Search_3").WebTable("DataTable").WebTable("Table").RowCount
      
      iCol = iCol + 1
      
      For i = 1 To CountOfRows
      	CustomerName=Browser("Meghalaya Directory Search").Page("Meghalaya Directory Search_3").WebTable("DataTable").WebTable("Table").GetCellData(i,3)
      	Address=Browser("Meghalaya Directory Search").Page("Meghalaya Directory Search_3").WebTable("DataTable").WebTable("Table").GetCellData(i,4)
      	xlSheet.Rows(i).Columns(iCol).Value =CustomerName
      	xlSheet.Rows(i).Columns(iCol + 1).Value =Address
      	iNewcolumn=xlSheet.UsedRange.Columns.Count + 1
      Next
      'xlBook.Save
      'xlBook.Close
      'xlApp.Quit
      
      Browser("Meghalaya Directory Search").Page("Meghalaya Directory Search_3").WebTable("LinkTable").Link("2").Click
      
    • Anu May 19, 2010, 3:31 am

      Hi Anshoo,

      Thnxs for your reply……………………………….

      I had tried the code given by you but when i click on the next link it overrides the previous data.

      I have parameterized the below link for navigating to the other web page:
      Browser(“Meghalaya Directory Search”).Page(“Meghalaya Directory Search_3″).WebTable(“LinkTable”).Link(“2″).Click
      Here i have parameterized the Link(“2″) that is in the object repository.
      When i run the script then it automatically goes to the next link and write data to excel sheet by overwritting the previous data.
      My problem is that-”I want data should not overwrite instead it should get append same as happen if we write data in txt”

      Hope u have understand my problem…………………

      Regards,
      Anu

    • Anonymous May 23, 2010, 10:55 pm

      Hi Anshoo,

      Could you please look at out my query mentioned above.
      Waiting for your response.
      Thanks in advance…………………………..

      Regards
      Anu

    • Anonymous May 26, 2010, 12:12 am

      Hi Anshoo,

      Hope u r doing well.
      Could you please look out my query so that i can proceed further.
      I will be highly thankful for your support.
      Waiting for reply…………….

      Regards,
      Anu

    • Anshoo Arora May 26, 2010, 8:48 am

      Its because you are not incrementing the columns when writing to Excel. You have static column numbers in your code:

      xlSheet.Rows(i).Columns(iCol + i).Value =CustomerName
      xlSheet.Rows(i).Columns(iCol + i + 1).Value =Address
      

      You must change these column numbers to increments:

      For i = 1 To CountOfRows-1
      	iCol = iCol + 1
      	CustomerName=Browser(“Meghalaya Directory Search”).Page(“Meghalaya Directory Search_3?).WebTable(“DataTable”).WebTable(“Table”).GetCellData(i,3)
      	Address=Browser(“Meghalaya Directory Search”).Page(“Meghalaya Directory Search_3?).WebTable(“DataTable”).WebTable(“Table”).GetCellData(i,4)
      	xlSheet.Rows(i).Columns(iCol).Value =CustomerName
      	xlSheet.Rows(i).Columns(iCol + 1).Value =Address
      	iNewcolumn=xlSheet.UsedRange.Columns.Count + 1
      	iCol = iCol + 1
      Next
      
    • Anonymous June 1, 2010, 11:03 pm

      Hi Anshoo,

      It works from my end………………….
      Thnks for yours valuable support……..

      Regards,
      Anu

  • Vishal Jhaveri May 10, 2010, 11:30 pm

    Hi Anshoo,
    Could you please provide me with a solution to my problem??
    I am using QTP’s datatable for Parameterization, my query is that i am using a local datatable for a particular action wherein i am storing user information such as: Username, Email Address, Password etc.
    Now the problem is that in my automation application i have to create a new user for subscription using these fields daily.
    Hence i am using Timestamp() function that generates a unique value which i append to these username, password, email address fields to create a unique user everytime and dump it into the application using
    .Set DataTable(“Username”, dtLocalSheet)+”"&UniqueValue1
    Now i am able to create a new user everytime, However there are certain cases where i have to login with the credentials of the already created user. hence i need to store these unique values in another datatable(Global) from where i can utilize them to login. Is there a way to do this. I know i can store them at runtime in another datatable, but its not of much use as it does not get stored permanantly and gets stored only at runtime.

    Is there a method to pick these valuse from one datatable, append the timestamp to it and store it in another datatable?
    Also if i am performing say 2 iterations then i want to store these values in different rows of the other datatable so that i can use them for other test cases.

    Please reply soon…
    Thanks
    Vishal Jhaveri

    Reply
    • Anshoo Arora May 12, 2010, 10:07 am

      Certainly possible. :)

      This is the only extra code required:

      sUserName = DataTable("Username", dtLocalSheet)+ "" & UniqueValue1
      DataTable("Username", dtLocalSheet) = sUserName
      

      Also, the values will only be viewed in the Runtime DataTable, not the design time.

      Not sure how the increments are running, but you *may* be required to use the following statement to enter the data in a new row each time:

      DataTable.LocalSheet.SetNextRow
      
  • Anonymous April 20, 2010, 5:13 pm

    Hi Guys,
    I am back with another question on QTP and need help here… My application which I am trying to automate is a 3rd party app deals with Space Management for associates. In this app we have a Javascript form that opens up after successful login and there are bunch of Text/Edit Box (Requested For) and drop down to select the data.

    A little information about the functionality I am trying to automate using QTP. There’s an Edit Box (Requested For) accepts user’s LAST NAME, FAST NAME. Next to this box is a small ‘lens’ icon (Click to Search) that populates user records based on user selection in Edit Box… For example… if user enters ‘jones’ it will display all the records for the user having LAST NAME starting with ‘jones’, FIRST NAME. Some of the columns in the Search results are Select (LastName, FirstName), Employee Number, Phone # etc… user’s name (lastname,first name) is a hyperlink — Link(“Paddon, Michael”).Click

    I need help in writing a QTP function that will automatically pick any random record or at least first record from Search Results…
    Here’s how I started:

    Dim myString
    myString = ” ”
    Browser(“MyQualnet”).Page(“Request Console”).WebEdit(“WebEdit”).Set myString
    ‘– some code that will select any random name from Search results and replace hard coded name – Link(“Paddon, ‘Michael”).Click
    Browser(“MyQualnet”).Page(“Request Console_2″).Link(“Paddon, Michael”).Click ‘ name is selected from the search results and is hard coded. I wanted to select this name randomly from Search results or at least the first record.

    I am totally lost and need help in writing this function.
    Any help in this regard will be appreciated.

    thanks,
    Raja

    Reply
  • Anonymous April 15, 2010, 3:02 am

    Hi Anshoo,

    could you plz explain me, why is that the test has run 4 times(above example) with the same set of data like

    1st time
    mercury mercury
    anshoo test123
    test test
    jhondoe mypassword

    2nd time
    mercury mercury
    anshoo test123
    test test
    jhondoe mypassword

    3rd time
    mercury mercury
    anshoo test123
    test test
    jhondoe mypassword

    4th time
    mercury mercury
    anshoo test123
    test test
    jhondoe mypassword

    what is the purpose behind it, as we are not creating any new set of data(even we are changing any combination – in between the test)

    plz explain me i am blank about this…

    Thank you

    Reply
  • andreas April 9, 2010, 3:27 am

    Hi Anshoo
    I’m working with QTP for automatisize an Siebel-Application. In my test, i have an action (action1) wich is parametriced on an local sheet with 10 rows. Inside action1 i want to use another action (action2), wich i want also paramtrice (for example with 2 rules). Inside of action2 i want to use a third action (action3) with the parametricing for example for 3 times. As result, the procedure shold work like this:
    action1 (row 1)
    action2 (row 1)
    action3 (3-times for row 1 till 3)
    action2 (row 2)
    action3 (3-times for row 1 till 3)
    action1 (row 2)
    action2 (row 1)
    action3 (3-times for row 1 till 3)
    action2 (row 2)
    action3 (3-times for row 1 till 3)
    action1 (row 3)

    How can i do this? is it poosible, to interleave actions?

    For an answer i would be very pleased
    Andreas

    Reply
  • Raja March 30, 2010, 8:04 pm

    Hi Guys,
    I am new to this forum on Relevantcodes and trying to learn QTP tool. I was trying to automate Yahoo Login page where my data is in LocalSheet (DataTable.GetSheet.(“Action1″)) of QTP having two columns “Yahoo_ID” and “Password”… I created 4 different yahoo Ids and passwords (one of them is correct obviously). Using parametrization, I was able to generate the code but unable to iterate through… it loads yahoo page, click yahoo mail, enters 1st data (username and password from dtLocalSheet) on Login page and spit out the result… I want it to iterate through all the records and then come out… Here’s what I did…

    rowcount = DataTable.GetSheet("Action1").GetCurrentRow
     For i  = 1 to rowcount
          DataTable.GetSheet("Action1").SetNextRow
    Next
    a = DataTable("Yahoo_ID",dtLocalSheet)
    b = DataTable("Password",dtLocalSheet)
    

    any help will be greatly appreciated.

    Thanks again for your help..
    Best,
    Raja

    Reply
    • Anshoo Arora April 1, 2010, 7:37 pm

      Hi Raja,

      Welcome to Relevant Codes! :)

      I think what you have is absolutely correct, but you may be missing the Action settings to iterate through all Rows. To do that:

      1. Open QTP -> Go to KeyWord View
      2. Under the Test Flow List -> If Action1 is selected -> Select Test Flow
      3. Right Click on Action1
      4. Click Action Call Properties
      5. Select Run On All Rows

      and you’re done!

    • Anonymous February 2, 2012, 12:38 am

      replace getcurrentrow with getrowcount

  • Puneet February 22, 2010, 10:47 am

    Hi Anshoo,

    I am unable to get QTP recognize the security and click on the link in the browser.

    Browser(“Certificate Error: Navigation_2″).Page(“Certificate Error: Navigation”).Link(“Continue to this website”).Click

    Thanks
    Puneet

    Reply
    • Anshoo Arora February 24, 2010, 8:24 am

      Puneet,

      You can try the below code:

      Browser("title:=Certificate Error.*").Link("innertext:=Continue.*").Click
      
  • Puneet February 22, 2010, 10:45 am

    Hi Anshoo,

    I have increment SSN by 1, is there any way to force QTP not to wirte it to the results. Because if I have increment by 1 10+ times then it is odd to have too much info in the test reuslts.

    Thanks
    Puneet

    Reply
    • Anshoo Arora February 24, 2010, 8:23 am

      Puneet,

      I think it depends how you are doing this. Are you using a Reporter.ReportEvent statement, or an Output CheckPoint or some other technique?

  • Puneet February 22, 2010, 12:20 am

    Hi Anshoo,

    Thanks for the code. I was able to add this to my code and use the Excel sheet to store my values. I am trying to open this webpage but I am unable to do you with this code. Any to program the QTP to click on the warning message?

    Browser(“title:=Certificate Error: Navigation”).Page(“title:=Certificate Error: Navigation”).Link(“name:=Continue to this website”).FireEvent “Click”

    Thanks
    Puneet

    Reply
    • Anshoo Arora February 24, 2010, 8:17 am

      Puneet,

      Are you trying to navigate ahead from a page like this one: http://helpdesk.ugent.be/img/cert_error1.png

      If yes, then I suppose the following code should work:

      Browser("title:=Certificate Error.*").Link("innertext:=Continue.*").Click
      
  • Puneet February 19, 2010, 4:07 pm

    I have another issue and that at the end of the application I am trying to move over the patient data to a website, before I can do it I have to change the website URL in the notepad which is located in the system.util unde the C: drive and I try to record this but I was not able to record it where it opens the file and change the URL in the notepad and save it. Am I suppose to do something different before recording?

    Thanks
    Puneet

    Reply
    • Anshoo Arora February 24, 2010, 8:12 am

      Puneet,

      Using the FileSystemObject (FSO) Object would be a better approach in this situation as compared to record and playback. I would recommend you to download all chapters of Scripting QuickTest Professional and read Chapter 14 for FSO. Good luck :)

  • Puneet February 19, 2010, 4:02 pm

    One thing I noticed is that I am getting the values from the datatable and if the value is selected from row 6 then the GetROProperty will store the value in the datatable in row 6 instead of from the beginning of the row and when I ran the following script then I will see it duing the run time but otherwise I don’t see it after the run time. Below is I am trying to store SSN. Thanks for your help.

    For x = 1 to maxRows
    datatable.SetCurrentRow(ssnRowNum)
    SwfWindow(“HA – You are currently”).SwfEdit(“txtNewSSN”).Type DataTable(“SSN”, dtGlobalSheet)
    enterSSN = SwfWindow(“HA – You are currently”).SwfEdit(“txtNewSSN”).GetROProperty(“text”)
    SwfWindow(“HA – You are currently”).SwfObject(“btnSSN”).Click 6,10

    If SwfWindow(“ePDHA – You are currently”).Dialog(“HA – [Confirm]_2″).Exist Then
    SwfWindow(“HA – You are currently”).Dialog(“HA – [Confirm]_2″).WinButton(“OK”).Click
    ssnRowNum = ssnRowNum + 1
    End if

    If SwfWindow(“HA – You are currently”).SwfEdit(“txtNewSSN”).GetVisibleText = “xxx-xx-xxxx” Then
    Exit for
    End If
    next

    num = enterSSN
    SwfWindow(“HA – You are currently”).SwfEdit(“txtVerifySSN”).Set num
    SwfWindow(“HA – You are currently”).SwfObject(“btnVerifySSN”).FireEvent “Click”

    DataTable(“SSN_VERIFY”, dtLocalSheet) = enterSSN

    Reply
    • Anshoo Arora February 24, 2010, 8:09 am

      Hi Puneet,

      Your observation is correct, but don’t you think it will be easier to correspond the test-time and run-time data because they both land on the same rows? I will be confused if the data for Row 6 ends up on some other DataTable row..

      but otherwise I don’t see it after the run time.

      It should be in the Run Time DataTable when you open the Results? Is it not there?

      I saw your code, and it seems correct as long as the value ssnRowNum points to the correct value of the DataTable..

  • Puneet February 18, 2010, 3:39 pm

    Hi Anshoo,

    I have created a new patient from the datatable and now I want the provider to log into the system and take the new patient and verify it and submit it through the application and then verify it that it has gone through to the website. If I have created mutliple patients then it should store in a datatable and use those values to verify each patient and submit. Once submitted then another user can go the website and verify the patient have been successfully listed in the website. Do you know what is the best approach will be?

    Thanks
    Puneet

    Reply
    • Anshoo Arora February 19, 2010, 2:12 am

      Puneet,

      I think it depends how you are creating the new patients and verifying them. The 2 instances are described below:

      Creating and Verifying patients within the same iteration
      This is quite simple and can be done by the use of variables. Example:

      sName = sName_FromTheApplicationUsingGetROProperty
      iAge = iAge_FromTheApplicationUsingGetROProperty
      

      and the variables sName and iAge can be used when testing for verification throgh the Provider.

      Creating all first. Verify all later.
      This is where you would need to store the patient information in a Table, either a DataTable or Excel spreadsheet. I generally use Excel Spreadsheets, but with the DataTable, the process is quite similar. You would need to create the columns in the DataTable that would contain the patient’s information.

      For example, if the patient has the following information to be written to the DataTable, then appropriate columns would have to be created:

      Name | Age | Alergies | Weight

      When creating patients, information would be written to these fields:

      DataTable("Name", dtLocalSheet) = sName_FromTheApplicationUsingGetROProperty
      DataTable("Age", dtLocalSheet) = iAge_FromTheApplicationUsingGetROProperty
      

      and written to the instance where Provider is verifying information:

      NameField = DataTable("Name", dtLocalSheet)
      AgeField = DataTable("Age", dtLocalSheet)
      
  • vartika February 11, 2010, 10:55 am

    How can we pass “local datatable” parameters in Actions.

    Reply
    • Anshoo Arora February 11, 2010, 2:31 pm

      Hi Vartika,

      Do you mean to retrieve stored data in the DataTable from within Actions? If yes, consider Action1 with its Local DataTable and the following fields:

      FirstName | LastName | Age | Gender | SSN
      John      | Smith    | 20  | Male   | XX
      Mary      | Smith    | 22  | Female | XX
      

      To retrieve the data from one of the columns, you would use the following code:

      sFirstName = DataTable("FirstName", dtLocalSheet)
      sLastName = DataTable("LastName", dtLocalSheet)
      iAge = DataTable("Age", dtLocalSheet)
      sGender = DataTable("Gender", dtLocalSheet)
      lngSSN = DataTable("SSN", dtLocalSheet)
      
    • Anonymous February 17, 2010, 2:45 pm

      How do we pass datable items as parameters to another action.
      say Action1 has firstname, lastname and you want to use those in Action2.

    • Anshoo Arora February 19, 2010, 2:01 am

      Hello,

      I think the entire process is documented in the help file, and a quick-overview of it could be found here: http://aboutqtp10.blogspot.com/2009/11/quicktest-professional-passing.html

      I have written a draft on this topic as well, and should be published in the coming few days..

  • Pradeep Babu. R January 30, 2010, 10:39 am

    Hi Anshoo..
    All the documents here are useful to me. Thanks for everything..
    Could you please direct me how to do the follwing,

    I need to do one framework for my project. My basic need is to,
    1) Update an excel sheet with the order number received from the last page of my application.
    – Could you please give a sample script to get the value from GUI and update an excel sheet placed in some location.

    2) I need to run the script from QC and I need to update the order number from the last page with PASS/FAIL status.
    – Give a Basic idea how to connect, Run the particular test case in QC from QTP and a simple script/ program to run and update the status into QC.

    Since I am very new to QTP , I need a basic idea about this, I dont have any mentor, So it is taking too much time to read and there is no one to help when any steps fail. I searched in many places and none of the website is clear and no screenshots or step by step procedure is available. If you help me in this it would be more thankful.. :-)

    Thanks in advance :)

    Reply
    • Anshoo Arora February 2, 2010, 9:38 pm

      Hi Pradeep,

      I am currently working on an article that explains working with Excel, and I think that might help you for #1. I will try to release that article soon.

      When running from QC, all you need to do is create a connection to it through QTP. Once that’s done, all the results will be automatically exported to QC once the test finishes its execution.

    • Pradeep Babu. R February 13, 2010, 4:17 am

      Hi Anshoo ! Could you please give some input on this. I am in need to do this as soon as possible.
      —-
      Updating an excel sheet with the order number received from the last page of my application.
      – Could you please give a sample script to get the value from GUI and update an excel sheet placed in some location.

      – Give a Basic idea how to connect, Run the particular test case in QC from QTP and a simple script/ program to run and update the status into QC.

    • Anshoo Arora February 14, 2010, 2:00 am

      Hi Pradeep,

      To retrieve the data from any application, you can use .GetROProperty and to write to Excel, you can refer to this article which shows code snippets to retrieve data, but reverting the code can be used to write back to Excel. You can also find some code to write to Excel here: http://relevantcodes.com/descriptive-programming-dp-concepts-3-ordinal-identifiers-demo/#comment-2236

      Not sure what you mean by #2. Once you upload the scripts to QC, you can add them to the Test Lab and execute them.

  • Jayachandra January 19, 2010, 5:33 am

    HI Anshoo,

    The broken links which u provided site is automation , i am looking for some hard coded thng by which we can test in qtp

    Reply
    • Anshoo Arora January 20, 2010, 9:16 am

      I checked that solution, and its for QTP. What kind of solution you’re looking for? If its possible we can try to work something out.

  • Jayachandra January 8, 2010, 3:59 am

    Hi Anshoo,

    Can you post me how to work on Borken Links Please i m looking for some snippets.

    Thanks in Advance

    Th

    Reply
    • Anshoo Arora January 8, 2010, 10:02 am

      Hi Jayachandra,

      For testing broken links, please see the following link.

  • Jayachandra January 8, 2010, 1:23 am

    In the above example i got some doubt regarding after log of wid valid id and where is the next statment to run 2nd iteration.. thnxs.. anshoo

    Reply
    • Anshoo Arora January 8, 2010, 1:29 am

      When we use the DataTable, we refer to the Action’s “Action Call Properties” to determine how many iterations we would like to be run. If you see this image from this article, you will notice that I have created a setting that will enable the action to make use of all the 4 rows.

      Once we make that setting, the action will run the test on all 4 rows, thus, it will run 4 iterations for each username/password combination.

    • Jayachandra January 8, 2010, 1:34 am

      thnxs alot anshoo can you explain how to test the broken links .

      thanks in advance

  • Jayachandra January 8, 2010, 1:04 am

    HI Anshoo can you give me brief Description regarding datapool is it jst like a external file with which we are going to work? Can you be more precisely.. Thanks in advance..

    Jayachandra

    Reply
    • Anshoo Arora January 8, 2010, 1:27 am

      A Datapool can be anything that you pull data from for testing. This can be an Excel File, an Access/SQL database, a text file, XML file etc.

      For example, RelevantCodes[1]One uses an Excel File as its data pool.

  • Mahesh Upadhyay December 17, 2009, 5:47 am

    Hi Anshoo,

    Thanks for the help, i am able to see “Action Call Properties” in Keyboard View when i follow your given steps.

    Thanks
    Mahesh

    Reply
  • Mahesh Upadhyay December 4, 2009, 1:26 am

    Hi Anshoo,

    I am unable to see the call action properties in my Keyword view, i am using QTP 10.0 evaluation version, can you please tell me the substitute.

    Thanks
    Mahesh

    Reply
    • Anshoo Arora December 8, 2009, 9:48 pm

      Hi Mahesh,

      I am still in the process of downloading/installing QTP 10.0. As soon as its complete, I will check it and get back to you! This will also give me a chance to test the framework and find any defects with the new version – which seems quite buggy to me.

    • Anshoo Arora December 16, 2009, 2:39 pm

      Mahesh,

      Here is what you need to do to get to the Action’s Call Properties:

      1. In Keyword View, Click on the Drop-Down list right below the test name.
      This list generally contains Test Flow, Reusable Actions -> Action1, Action2 etc.
      2. Click on Test Flow
      3. Now you will have all actions in a hierarchical format
      4. Right-Click on any action.

      Once you perform the above steps, you will see “Action Call Properties” whenever you right-click on any Action.

  • Ranjini November 24, 2009, 1:49 am

    Hi Anshoo,
    As you thought us “data-pool can be QTP’s DataTable, an Excel Spreadsheet (external to QTP)”
    which is the best way to maintain/use it ? either QTP’s data table or external spreadsheet ?

    Thanks,
    Ranjini.

    Reply
    • Anshoo Arora November 24, 2009, 10:24 am

      Good question, Ranjini.

      I think its a matter of comfort level that makes people choose between the two. Which one are you the most comfortable with? If you use DataTable, you must be well versed with the methods of the DataTable. If you use an Excel spreadsheet, then you must be well versed with Excel’s COM Interface. That’s the usage component. I almost always use Excel, because I feel I can do more, and create my code with much better performance as I would with the DataTable.

      Maintenance is subjective, here. You can use an Excel spreadsheet and import it to QTP on runtime. You can even copy-paste the changes you made to an Excel spreadsheet to the DataTable. Similarly, you can export a DataTable sheet to Excel. So, I think this one is a little hard to answer – I guess a good thing to say in regards to this is a person’s comfort-level between the two.

  • Ranjini November 24, 2009, 1:45 am

    Hi Anshoo,
    For iterating the Datatable values is it enough if we change the Data table iterations in Action Call Properties dialog ? or we need to do change the setting under the File —>Setting —>Run –> data table iteration ?
    Why we have the data table iterations setting at 2 differnet places.
    i am sure that the questions is very basic but still i want to understand the reason behind it ? kindly clarify

    Thanks,
    Ranjini

    Reply
    • Anonymous November 24, 2009, 5:33 am

      hi
      ranjini
      Setting under File-setting iteration is for particular test. It is global setting.
      If we change in Action call property it is for Particular action not for entire test.So it is Local setting. Hence we have 2 sheets in Data table.

    • Ranjini November 24, 2009, 11:29 am

      Hi,
      Thanks for the response.
      If i need to parametrize my test both by Global and Local datatable sheet then Dt iterations setting has to be changed in both palces (Action properties and Test Setting)?

      Thanks,
      Ranjini

    • Anshoo Arora November 26, 2009, 5:50 pm

      Hi Ranjini,

      The concept with the Global DataTable is that, the “entire test” will run as many number of iterations as there are in the Global Table if its option is set to “Run on All Rows”.

      That means, if you have:

      2 rows in Global Table (Run on All Rows Option Selected)
      Action1: 4 Rows
      Action2: 3 Rows
      

      The total number of times the entire test will cycle is twice. That means, Action1 will have 8 iterations, and Action2 will have 6 iterations in all.

      Also, the setting for dtGlobalSheet (GlobalTable) is in the test settings, whereas for the actions, its in the Action Call Properties.

    • Ranjini November 30, 2009, 6:39 am

      Hi Anoosha,
      Very clear explanation. Thanks Verymuch

      Regards,
      Ranjini

    • Anshoo Arora November 30, 2009, 1:18 pm

      Thank you :)