I m setting the excel sheet path in QTP for importing as : datatable.importsheet "C:Qtpabc.xls" but if the location of excel sheet path changes to for eg:"D:Data"...the script fails as proper excel sheet path is not given..can u plz suggest how to use a environment variable/xml file to remove data path hard coding??

Showing Answers 1 - 2 of 2 Answers

vasavi

  • Jul 19th, 2006
 

Hi,

    You can use Action and Test parameters to  parameterize the hard coded value of Excel sheet path, or even  you can go  for Environment variables.

Using Test and Action parameter:

  Follow following procedure

Go to Test Settings-> Parameters-> define the input parameters (for ex: path)

As Test parameter can't be used directly in Test script, goto Correspoding Action an right click

and go to Action properties  and define  Action parameter to use.(for ex: path1)

then goto Action Call Properties-> and set value for defined action parameter

as Test parameter(in value column for that parameter  click  on the '<>' to set value and set Test parameter as parameter type and set "path" variable to Action parameter(path1)

and use same action parameter in the  datatable.import sheet statement

datatable.importsheet path1

When we run the Test   we can give the path of Excel sheet in "Run  dialog box->Paramters" .

Using of Environment variable

define an environment varibale in Test->settings->Environment parameters

Select parameter type as "Userdefined" from list box and define the  parameter

and use directly in datatable.importsheet statement. Here we need to give value of path  before executing the script.

let me know if u have any qts

Deepa

  • Jul 6th, 2007
 

I didn't get what you are trying to explain. Can you Plz explain it with an Example. My Prob is that I want to import data from an excel sheet into a database. ie to implement the insertion Process.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions