Winrunner Tutorial
Why Automate. Isn’t automation a pain in the ***??.Isn’t it trying to develop the application twice (First for developing the whole application and Second for developing test scripts which is as good as developing the whole application itself)?
Well, that’s true. But automation decreases the execution time many-fold. If it takes 10 testers to perform a particular test in a matter of 4 days, automation tools can do the whole in 1 day). So the management saves lot of time plus man-hours.
First take a moment to get a feel of the installation of WinRunner.If you have done all the default installations, you should see a WinRunner directory under Programs. Inside the folder, u will find a WinRunner executable, Uninstall WinRunner, SoftKey Configuration, Fonts Expert, Readme, Documentation folder,and Sample Application folder. Now if you point to Sample Applications, you will find a Flight 1A, Flight 1B, Visual Basic Flight 1A, Visual Basic Flight 1B applications. Now each of these sample applications are unique in their own ways. For our course, we are going to use these applications as AUT (Application Under Test).In the real world, you use WinRunner to perform functional and regression testing on applications. (In our world, we are going to use WinRunner to do functional and regression testing on Flight application).
Take a moment to study the Flight Application 1A. if you click on it, it will open a Login Window. There are two fields in this window namely Agent Name, Password. There are 3 buttons, “OK”, “Cancel “ and “help”. Remember the password is case insensitive ‘mercury’. You can use any login id to log into it.
Let’s walk thru the WinRunner application.
You will find a toolbar on WinRunner like here. Apart from the New, Open and Save button you will find a ListBox for RunMode. If you select it you will find three modes, Verify, Update and Debug. These are the modes that you will use when running a WinRunner script. (more details later). The Red buton is for recording. The green arrow placed on a stack holder is to Run from the Top. Basically it runs your scripts from line # 1. The green arrow with a purple Line pointer is Run from the Current Line. Basically you can run a winrunner script from a selected line, in which case you use Run from the arrow. The stop button is used to Stop any recording that you would’ve done. The pause is to pause a particular run. And the remaining buttons are used for debugger.
Lets start of by recording a simple script.
Scenario:
Open the Flight Reservation application. Open WinRunner. Resize the WinRunner Window such that the Login screen and WinRunner are visible without any overlap.
Click the record button on WinRunner application, and perform the following operations on the Login Screen
Enter as the agent name : active
Enter Password as : venus
Click on “OK” button.
A screen pops up. Click ok button on this screen.
Click the stop button on WinRunner application.
At this time, the recording has stopped.And you can play-back (run) your scripts. If you see you WinRunner application, it would have developed some code for you. Notice you only perform your actions on the application and winrunner develops code for u.
Save the script. Call “myfirst” .
The code looks somewhat similar to this. (There maybe a few additional lines in your code )
#Login Window
set_window ('Login', 4);
edit_set ('AgentsName', “active”);
password_edit_set('Password', “***********”);
button_press ('OK');
#Flight Reservation Message Window
set_window ('Flight Reservation Message', 2);
button_press ('OK');
Note:--- Comments in WinRunner scripts are identified by the # sign. Anything after the # sign until the end of the line is a comment. So in the above script you will find a couple of comments and can ignore. WinRunner usually inserts comments during recording phase itself.
Note:--- The actual numbers (second arguments) in your code maybe different. These number’s represent the time lag between the two statements (two actions rather) during recording. More on this later.
Note :--- When you save a WinRunner script, WinRunner creates a folder by the name you entered. In the folder, there is a file called ‘script’. This is a plain ascii file. You can open it in Notepad, and see your script. This file contains the code that you’ve developed.
You can run your code now to see the action it performs. In order to run your code, click the Run from the top button. You can run your code in two modes. Debug Mode and Verify Mode. Debug Mode is used in the development stage of test scripts. In this stage you don’t care about test results (because you are yet to develop test scripts). Once all the scripts have been developed, you use Verify Mode.
For Now you can click Run from the top in Verify mode, and click on OK again. Or you can select Debug mode, and run your scripts.
Let’s walk thru the code.
Set_window () statement is responsible for focusing the window. Remember when working with different windows, you can perform any action on a focused window. But not on a unfocussed window. So when you click the login window (after click the record button), WinRunner will automatically detect that the login window is in focus and record a set_Window() statement.
edit_set() statement. Remember when you typed in the agent name in a edit field, winrunner recognized this field as a edit_field, and hence inserted the edit_set statement. In this case, it identified the name of the field as 'AgentsName'. edit_set statement takes two arguments. The first argument is the name of the field, and the second argument is its value (basically whatever you type).In this case, you have typed “active” in the Agent Name field and therefore WinRunner identifies this and generates the edit_set statement accordingly.
password_edit_setstatement is similar to edit_set, except that since passwords are encrypted fields and are to be displayed as *****, (asteriks) instead of the actual values.
Button_press() statement is used to whenever you perform a click on any button. In this case, you have pressed the OK button in the Login screen and hence WinRunner generates that statement. And also you perform another button_press() statement on the Flight Reservation Message Window by clicking on Ok.
In your WinRunner window, there is a small yellow arrow that you can find in the left bar of your WinRunner window. Its a line pointer, that points to the current line of execution. You can select any line of code, and start execution from that point. (Essentially, you don’t always have to start execution from line 1). You can use these techniques during the development of test scripts. In order to execute from line#10, on the left bar, click the area that corresponds to line # 10. You will find that the yellow pointer has moved to that area.And then select “Run From arrow” from the toolbar. You will see that WinRunner executes code from that area.
The Way WinRunner Works: WinRunner hooks into the Operating system, and monitors all actions that you perform on applications. Whenever you perform any action on an object like lets say in the Login Window, You click the OK button, WinRunner identifies the physical properties of this object. It then creates a logical name for this object also. (Because it is convenient to use Logical names as opposed to physical names). You can actually see it working. From the Menu selectTools à GUI Map Editor. And you will see a GUI Map file. Its called default.gui ( this is the default name that is selected when you save a script). This GUI Map contains a list of all the windows and objects in that window that you have worked on. If you expand a window in the GUI map editor, you will see all objects in a window. If you select any object, you will find its physical description in the bottom. The Logical name is what you find in the list. You can click on Modify button, to modify any of its logical name or physical name.If you modify the physical description, you will run into the danger of the code not running cleanly because the object is no longer identified. If you change the logical name, you can still run your code with some modifications. The modifications needed are to change all existing instances of the object’s Previous Logical name to the current Logical Name.
So in the above case, select the Login Window and expand it. You will see a OKinside it. Select the “OK” and click on modify button and change the Logical Name from “OK” tolets say “start”. And save your gui Map file.
Now if you run your code, again, it wont work. Because you have changed the Logical name of “OK” object to “start”. In your code, change the button_press statement of the object that corresponds to the logical name you have changed.
Old statement:
Button_press(“OK”);
New Statement
Button_press(“start”);
Don’t change the other button_press statement. Because the other OK corresponds to a different object. That object is found in the Flight Reservation Message window and not Login Window.
Parameterization:--
What is Parameterization. Just the ability to record and run your scripts is no fun. What if you want to run the test for a different data. Do you have to create a whole different test script to run it for a different data. The answer to the above question is. You can develop the script once and run it with different Data by parameterizing your script. Notice in the above script, you have hard coded the data (agentname and password). Now instead of hard-coding them, we will parameterize them from an excel spreadsheet.
From the Tools Menu, select Data Table
It will open an excel spreadsheet. You can name the columns. Double click on the first column in the top gray area ( I think you can click on A). It will open pop-up where you can enter the name. In the name field give Agent_Name. In the Next column, double click it, and give the name as password. So your data table has two columns. Agent_Name and password.Octet stream to base64 java.
Now give the following pairs of data in each row.
Prima | vera |
Zina | amazon |
David | korn |
penelop | Cruz |
bradd | Pitt |
henry | hinmen |
And save the data table.
It is automatically saved to default.xls.
In order to parameterize your current script,
From the Menu, select Tools à Data Driver Wizard
In the following Welcome screen, click Next,
In the Use a new or existing Excel table box, type or navigate to your data table (You can navigate by clicking the button next to the field).
Select Add statements to create a data driven test.
Select Parameter the Test
And choose Line by Line.
Click Next
Now all lines that can be parameterized start appearing. (The wizard automatically chooses only those lines that can be parameterized). Choose An existing column and select your column name. Repeat this process until the wizard has finished parameterizing all statements.
And then you will see WinRunner has modified your script.
Linkin Park returned to the recording studios in 2006 to work on new material. To produce the album, the band chose producer Rick Rubin. The album also took the top spot on the Billboard Charts. The album included singles like 'What I've Done', 'Shadow of the Day'. Sign in now to see your channels and recommendations! Watch Queue Queue. Linkin park top songs. Linkin Park new songs, albums, biography, chart history, photos, videos, news, and more on Billboard, the go-to source for what's hot in music. Linkin Park Rules Top Facebook Live Videos Chart.
You can run the script too see it working. But you may run into some problems. (For today’s assignment, this is exactly what I require you to do.More about the assignment later)
Before Going ahead,
I want you to take read the WinRunner tutorial completely before going ahead.
And keep the following in mind before going ahead.
1. GUI Spyà a tool provided in WinRunner (under the Tools menu) that is used to know the physical properties of an object.
2. GUI Map Editor à its another tool provided in WinRunner that is used to list all the objects (their logical names and physical properties). If you are working on a particular object, it has to be there in the GUI map editor.
3. GUI Map, it’s a file that is present in every WinRunner script that contains a map between a logical name of an object and its physical description.
4. In order to develop scripts in WinRunner, you will definitely need a GUI Map because, GUI Map helps WinRunner Identify the objects in AUT. There are two ways to start working in WinRunner.You can directly record your script and enhance it. That way, WinRunner will learn only those Objects that were acted upon. Or you can choose to learn the complete GUI Map of the application. In order to learn the complete GUI Map of the application you can use the Rapid TSL script wizard under tools menu.
5. Recording is of two types. 1. Context Sensitive 2. Analog
Almost always you use Context Sensitive Recording. It is indifferent to Mouse movements. Analog recording capture mouse movements too (the scripts developed using this type of recording are not intuitive and are difficult to maintain). We will revisit this topic.
6. Just another note. You can click F1 key on any line in WinRunner script to read more about that function. It will open the online reference Guide.
Read the complete WinRunner Tutorial. And then read the following topics in User’s GUIDE.
Go thru the 2 items in WinRunner users guide.
1.Understanding The GUI map
2.Creating Tests
Here are some of the common functions that we will come across.
I suggest you to take a moment and go thru the TSL online Reference Guide and read about these functions, their parameters etc.
1.Set_window();
2.Win_activate();
3.invoke_application();
4.win_exists();
5.edit_set();
6.button_press();
7.win_close();
Note. If you need to check for any window like say- You want to test if the Login Window is available or not.
Use the following code snippet.
If (win_exists (“Login”, 2) = = E_OK)
{
# The window exists
# Do whatever
}
else
{
# the window doesn’t exist.
# do whatever
- Categories
- Top types
- Audio & home theatre
- Cameras & camcorders
- Computer cables
- Computer components
- Computers
- Data input devices
- Data storage
- Networking
- Print & Scan
- Projectors
- Smart wearables
- Software
- Telecom & navigation
- TVs & monitors
- Warranty & support
- other →
- Top brands
- Acer
- AEG
- Aeg-Electrolux
- Asus
- Canon
- Casio
- Electrolux
- HP
- LG
- Nikon
- Panasonic
- Philips
- Samsung
- Sony
- Yamaha
- other →
- Top types
- Infotainment
- Musical instruments
- Video games & consoles
- other →
- Top brands
- Acer
- AEG
- Asus
- Dometic
- Electrolux
- HP
- Juno
- Panasonic
- Philips
- Progress
- Samsung
- Sharp
- Sony
- ZANKER
- Zoppas
- other →
- Top types
- Binding machines
- Boards
- Calculators
- Correction media
- Desk accessories & supplies
- Drawing supplies
- Equipment cleansing kit
- Folders, binders & indexes
- Laminators
- Mail supplies
- Paper cutters
- Sorters
- Storage accessories for office machines
- Typewriters
- Writing instruments
- other →
- Top brands
- Bosch
- Canon
- Casio
- Craftsman
- Dell
- Epson
- Fujitsu
- HP
- KitchenAid
- LG
- Panasonic
- Philips
- Samsung
- Sharp
- Smeg
- other →
- Top types
- Bedding & linens
- Cleaning & disinfecting
- Do-It-Yourself tools
- Domestic appliances
- Home décor
- Home furniture
- Home security & automation
- Kitchen & houseware accessories
- Kitchenware
- Lighting
- other →
- Top brands
- AEG
- Aeg-Electrolux
- Bosch
- Electrolux
- HP
- IKEA
- Indesit
- LG
- Panasonic
- Philips
- Progress
- Samsung
- Sony
- Whirlpool
- Zanussi
- other →
- Top types
- Bags & cases
- Children carnival costumes
- Clothing care
- Clothing hangers
- Dry cleaners
- Fabric shavers
- Men's clothing
- Tie holders
- Ultrasonic cleaning equipment
- Watches
- Women's clothing
- other →
- Top brands
- Braun
- Casio
- Citizen
- Garmin
- Huawei
- Indesit
- LG
- Mitsubishi Electric
- Philips
- Radio Shack
- SEVERIN
- Sony
- V7
- Velleman
- ZyXEL
- other →
- Top types
- Air Handlers
- Boom Lifts
- Compact Excavator
- Elevators
- Excavators
- Finishers
- Front End Loaders
- Noise Reduction Machine
- Oxygen Equipment
- Robotics
- Scrubber
- Spreader
- Tractor
- Trash Compactor
- Welding System
- other →
- Top brands
- AEG
- Aeg-Electrolux
- Asus
- Canon
- Casio
- Electrolux
- HP
- LG
- Nikon
- Panasonic
- Philips
- Samsung
- Sony
- Whirlpool
- Yamaha
- other →
- Top types
- Blood pressure units
- Electric toothbrushes
- Epilators
- Feminine hygiene products
- Foot baths
- Hair trimmers & clippers
- Makeup & manicure cases
- Men's shavers
- Personal paper products
- Personal scales
- Shaver accessories
- Skin care
- Solariums
- Teeth care
- Women's shavers
- other →
- Top brands
- AEG
- Aeg-Electrolux
- Bosch
- Canon
- Casio
- Electrolux
- KitchenAid
- LG
- Panasonic
- Philips
- Samsung
- Sony
- Whirlpool
- Yamaha
- Zanussi
- other →
- Top types
- Hot beverage supplies
- other →
- Top brands
- other →
- Top types
- Cars
- Electric scooters
- Motor vehicle accessories & components
- Motor vehicle electronics
- Motorcycles
- Motorhomes
- Offroad Vehicle
- Scooters
- Utility Vehicle
- other →
- Top brands
- AEG
- Aeg-Electrolux
- Bosch
- Canon
- Casio
- Craftsman
- Electrolux
- LG
- Panasonic
- Philips
- Samsung
- Sharp
- Sony
- Yamaha
- Zanussi
- other →
- Top types
- Baby bathing & potting
- Baby furniture
- Baby safety
- Baby sleeping & bedding
- Baby travel
- Feeding, diapering & nursing
- Toys & accessories
- other →
- Top brands
- AEG
- Asus
- Bosch
- Canon
- Casio
- Electrolux
- HP
- LG
- Panasonic
- Philips
- Samsung
- Sony
- Whirlpool
- Yamaha
- Zanussi
- other →
- Top types
- Bicycles & accessories
- Bubble machines
- Camping, tourism & outdoor
- Fitness, gymnastics & weight training
- Martial arts equipment
- Skateboarding & skating
- Smoke machines
- Sport protective gear
- Target & table games
- Water sports equipment
- Winter sports equipment
- other →
- Top brands
- Craftsman
- Daikin
- Emerson
- Epson
- Frigidaire
- Harbor Freight Tools
- HP
- Miele
- Philips
- ProForm
- Samsung
- Sears
- Sennheiser
- Weider
- Yamaha
- other →
- Top types
- Pet hair clippers
- other →
- Top brands
- Andis
- other →
- Top types
- Pill Reminder Device
- Stairlifts
- other →
- Top brands
- Alber
- Bruno
- E-PIL
- Minivator
- Savaria
- other →