Você está na página 1de 10

Write a vb script which access the excel file empfile1.xls. Caluculate bonus = Salary * grade/100.

Where grade can be 1-4. Total = salary + Bonus. And save in same excel sheet. Create a text file and for each employee in which it is written Here by we glad to give diwali bonus to ------NAME of Employee----------- Rs.----------------. Wish you a very happy Diwali and prosperous new year!!!!!!!!! and save it with empnameddmmyyhhmm.txt format.

Create a script without using OR ( With Descriptive programing) for booking a flight using newtours.demoaut.com. 1. Please create a script fot booking a flight using newtours.demoaut.com site with creating a action for each page of Navigation. 2. Please create a script fot booking a flight using newtours.demoaut.com site with creating a function for each page of Navigation

1.Write a program to add all numbers from x to y where x and y are user input using do while loop. 2. Create two arrays one for odd numbers and one for even numbers between x and y numbers where x and y are user input. 3. Write a program to give the name of the month when user enter month number without using monthname function and using Select case statement. 4. Write a function for inserting an order in flight application and getting order number. Now using this order number update the order for different name and at last delete the order. Here you are suppose to write three functions insertorder, updateorder and delete order. **************************************************************************
Open the dat folder in the following path: C:/ProgramFiles/MercuryInteractive/QuickTestProfessional/dat 2. Check whether "Actiontemplate.mst" file exist in Dat folder if not Create a notepad in that folder. 3. Enter the text you want get displayed in QTP by default. Use single quotes ' before the text so as to make it a comment. E.g. 'TestScript Name: 'Date Created: 4.Save the file as "Actiontemplate.mst" That's it. Whenever you open the QTP you can see the text added in Actiontemplate by default Steps to create Action Template : 1. Open Note Pad 2. Type The Comments Want To Include like Eg:'Test Name: 'Action Name: 'Action Description: 'Resources: 'Author:

'Modified Fields: 'Date: Etc....... 3. Go to File --> Save As 4. Save the file Like This "ActionTemplate.mst" in Dat Folder (C:/ProgramFiles/MercuryInteractive/QuickTestProfessional/dat) After Saving When Open the QTP the comment lines displays in every Action o

Few guidelines to follow when working with actions in QTP: 1. If your action runs more than one iteration, the action must end at the same point in your application as it started, so that it can run another iteration without interruption. For example, suppose you are testing a sample flight reservation site. If the action starts with a blank flight reservation form, it should conclude with a blank flight reservation form. 2. A single test may include both global Data Table parameters and action (local) Data Table parameters. For example, you can create a test in which a travel agent logs into the flight reservation system, books three flights, and logs out; the next travel agent logs into the flight reservation system, books three flights, logs out, and so forth. To parameterize the `book a flight action, you choose Current action sheet (local) in the parameterization dialog box and enter the three flights into the relevant Action tab in the Data Table. To parameterize the entire test, you choose Global in the parameterization dialog box and enter the login names and passwords for the different agents into the Global tab in the Data Table. Your entire test will run one time for each row in the Global data sheet. Within each test, each parameterized action will be repeated depending on the number of rows in its data sheet and according to the run settings selected in the Run tab of the Action Properties dialog box. 3. You may want to rename the actions in your test with descriptive names to help you identify them. It is also a good idea to add detailed action descriptions. This facilitates inserting actions from one test to another. You can rename an action by choosing Edit > Action > Rename Action. (Make sure you follow the naming conventions for actions.) 4. If you plan to use an identical or virtually identical procedure in more than one test, you should consider inserting a call to an action from another test. - If you want to make slight modifications to the action in only one test, you should use the Insert Call to Copy of Action option to create a copy of the action. - If you want modifications to affect all tests containing the action, you should use

the Insert Call to Existing Action option to insert a link to the action from the original test. - If you want modifications to the action to affect all tests containing the action, but you want to edit data in a specific tests Data Table, use the Insert Call to Existing Action option and, in the External tab of the Action Properties dialog box, select Use a local, editable copy. 5. When you insert a call to an external action, the action is inserted in read-only format, so the Record button is disabled. If you want to continue recording, you first need to insert a call to a local action into your test, or select a step from a local action that already exists in your test. 6. Reusable actions help you to maintain your tests, but it is important to consider the effects of making an action reusable. Once you make an action reusable, be sure to consider how changes to that action could potentially affect other tests that call that action. 7. If you expect other users to open your tests and all actions in your tests are stored in the same drive, you should use relative paths for your reusable actions so that other users will be able to open your tests even if they have mapped their network drives differently. 8. If you expect certain elements of your application to change regularly, it is a good idea to divide the steps related to changeable elements into a separate action so that it will be easy to change the required steps, if necessary, after the application is modified. 9. If you decide to remove an action, consider how that might affect your test or another test that contains a call to that action. For example, will it prevent a later action in the same test from running correctly? Will it cause the test containing a call to that action to fail?

When working with tests, the Data Table is saved with your test by default. You can save the Data Table in another location and instruct the test to use this Data Table when running a test. You specify a name and location for the Data Table in the Resources pane of the Test Settings dialog box. You configure the location of the Data Table in Resources pane of the Test Settings dialog box (File > Settings > Resources node).

If you select an external file as your Data Table, you must make sure that the column names in the external Data Table match the parameter names in the test and that the sheets in the external Data Table match the action names in the test.

All methods apply to the run-time DataTable object only. Changes to the run-timeDataTable object are reflected in the test results, but the design time Data Table is not affected DataTable Object - Methods AddSheet Method Adds the specified sheet to the run-time Data Table. e.g. Variable=DataTable.AddSheet ("MySheet").AddParameter("Time", "8:00") DeleteSheet Method Deletes the specified sheet from the run-time Data Table. e.g. DataTable.DeleteSheet "MySheet" Export Method Saves a copy of the run-time Data Table in the specified location. e.g. DataTable.Export ("C:\flights.xls") ExportSheet Method Exports a specified sheet of the run-time Data Table to the specified file. e.g. DataTable.ExportSheet "C:\name.xls" ,1 GetCurrentRow Method Returns the current (active) row in the first sheet in the run-time Data Table (global sheet). e.g. row = DataTable.GetCurrentRow Reporter.ReportEvent 1, "Row Number", row GetRowCount Method Returns the total number of rows in the longest column in the first sheet in the run-time Data Table (global sheet). e.g. rowcount = DataTable.GetSheet("MySheet").GetRowCount Reporter.ReportEvent 2, "There are "&rowcount, "rows in the data sheet." GetSheet Method Returns the specified sheet from the run-time Data Table. e.g. DataTable.GetSheet ("MySheet").AddParameter "Time", "8:00" GetSheetCount Method Returns the total number of sheets in the run-time Data Table.

e.g. sheetcount = DataTable.GetSheetCount Reporter.ReportEvent 0, "Sheet number", "There are "&sheetcount& " sheets in the Data Table." Import Method Imports the specified Microsoft Excel file to the run-time Data Table. e.g. DataTable.Import ("C:\flights.xls") ImportSheet Method Imports a sheet of a specified file to a specified sheet in the run-time Data Table. The data in the imported sheet replaces the data in the destination sheet (seeSheetDest argument). e.g. DataTable.ImportSheet "C:\name.xls" ,1 ,"name" SetCurrentRow Method Sets the specified row as the current (active) row in the run-time Data Table. e.g. DataTable.SetCurrentRow (2) SetNextRow Method Sets the row after the current (active) row as the new current row in the run-time Data Table. e.g. DataTable.GetSheet("MySheet").SetNextRow SetPrevRow Method Sets the row above the current (active) row as the new current (active) row in the run-time Data Table. e.g. DataTable.SetPrevRow DataTable Object - Properties GlobalSheet Property Returns the first sheet in the run-time Data Table (global sheet). e.g. DataTable.GlobalSheet.AddParameter "Time", "5:45" LocalSheet Property Returns the current (active) local sheet of the run-time Data Table. e.g. MyParam=DataTable.LocalSheet.AddParameter("Time", "5:45") RawValue Property Retrieves the raw value of the cell in the specified parameter and the current row of the run-time Data Table. The raw value is the actual string written in a

cell before the cell has been computed, such as the actual text from a formula. e.g. FormulaVal=DataTable.RawValue ("Date", "ActionA") Value Property DataTable default property. Retrieves or sets the value of the cell in the specified parameter and the current row of the run-time Data Table. e.g. DataTable.Value (2,3)="New York"

DTParameter - Methods DTSheet.AddParameter 'add a new column e.g. DataTable.GetSheet("dtGlobalSheet").AddParameter "NewColumn","Row1Value" DTSheet.GetParameter Retrieves the specified parameter from the run-time Data Table sheet. e.g. DataTable.GetSheet("MySheet").GetParameter("Destination") DTParameter - Properties Name Property The name of the parameter (column) in the run-time Data Table. e.g. paramname = DataTable.LocalSheet.AddParameter("Food", "pizza").Name Reporter.ReportEvent 1, "The New Parameter name is", paramname RawValue Property The raw value of the cell in the current row of the parameter in the run-time Data Table. The raw value is the actual string written in a cell before the cell has been computed, such as the actual text from a formula. The following example uses the RawValue property to find the formula used in the current row of the Date column in the ActionA sheet of the run-time Data Table. The statement below returns the value: =NOW() FormulaVal=DataTable.GetSheet("ActionA").GetParameter("Date").RawValue Value Property Parameter default property. Retrieves or sets the value of the cell in the current (active) row of the parameter in the run-time Data Table. e.g. DataTable.GetSheet("ActionA").GetParameter("Destination").Value="New York" ValueByRow Property

Retrieves the value of the cell in the specified row of the parameter in the run-time Data Table. e.g. DataTable.GetSheet("ActionA").GetParameter("Destination").ValueByRow(4)

DTSheet - Methods AddParameter Method Adds the specified parameter (column) to the sheet in the run-time Data Table, sets the value of the first row to the specified value, and returns the parameter so that you can directly set or retrieve properties of the new parameter in the same statement. e.g. Variable=DataTable.AddSheet ("MySheet").AddParameter("Time", "8:00") DeleteParameter Method Deletes the specified parameter from the sheet in the run-time Data Table. The following example uses the DeleteParameter method to delete the parameter, "Arrival" from the "MySheet" sheet of the run-time Data Table. DataTable.GetSheet("MySheet").DeleteParameter("Arrival") GetCurrentRow Method Returns the row number of the current (active) row in the run-time Data Table sheet. e.g. row = DataTable.GetSheet("MySheet").GetCurrentRow Reporter.ReportEvent 1, "Row Number", row GetParameter Method Retrieves the specified parameter from the run-time Data Table sheet. e.g. DataTable.GetSheet("MySheet").GetParameter("Destination") GetParameterCount Method Returns the total number of parameters (columns) in the run-time Data Table sheet. e.g. paramcount = DataTable.GetSheet("MySheet").GetParameterCount Reporter.ReportEvent 2, "There are "&paramcount, "columns in the data sheet." GetRowCount Method Returns the total number of rows in the longest column in the run-time Data Table sheet. e.g. rowcount = DataTable.GetSheet("MySheet").GetRowCount Reporter.ReportEvent 2, "There are "&rowcount, "rows in the data sheet."

SetCurrentRow Method Sets the specified row as the current (active) row in the run-time Data Table. e.g. DataTable.GetSheet("MySheet").SetCurrentRow(2) SetNextRow Method Sets the row after the current (active) row as the new current row in the run-time Data Table sheet. e.g. DataTable.GetSheet("MySheet").SetNextRow SetPrevRow Method Sets the row above the current (active) row as the new current (active) row in the run-time Data Table sheet. e.g. DataTable.GetSheet("MySheet").SetPrevRow DTSheet - Properties Name Property Returns the name of the run-time data sheet. e.g. Sheetname = DataTable.LocalSheet.Name Reporter.ReportEvent 1, "The Active Sheet is", Sheetname

***************************PROGRAMS & CONDITIONS******************************** 1. For step+1 stp = inputbox("step =") For i=1 to 20 step stp msgbox "No skiped by step "&stp& " = "&i next

2. For Step-1 stp = inputbox("step =") For i=20 to 1 step -stp msgbox "No skiped by step "&stp& " = "&i next 3. For Each: Dim cars(2) cars(0)="Volvo" cars(1)="Saab" cars(2)="BMW" For Each x In cars msgbox(x) Next 4. Do While: Dim VarData Dim Flag Flag= "y" do VarData=Inputbox("Please Enter number less then 10") if(VarData< 10) then msgbox("You are great") exit do else msgbox("better try next time") end if loop while(Flag="y") 5. DO UNTIL: dim i i=1 do until(i>10) msgbox (i) i=i+1 loop 6. WHILE WEND: Dim i i=1 While(i<10)

msgbox (i) i=i+1 wend 7. ARRAY FUNCTIONS: Dim a msgbox (IsArray(a)) a=Array(10,20,30) msgbox (IsArray(a)) msgbox (LBound(a)) msgbox (UBound(a)) For i=Lbound(a) to Ubound(a) msgbox (a(i)) next 8.

Você também pode gostar