If you want to create WinRunner scripts that are highly efficient, there are important programming concepts that you will want to become familiar with. Understanding these concepts will provide you with a large number of key benefits. In addition to understanding these concepts, you must also learn how to combine them with TSL, or the Test Script Language.
The very first concept that you will want to become familiar with is variables. Variables are used in many programs, and it is basically a character or group of characters that serves as a representative for a string. When table paths are transformed into variables, they will make a number of changes to code.
When variables are used with table paths, they will be much easier to read. In addition to this, they are also easier to process. If the table path becomes altered, all you will need to do is change the table path in one place, and this change will be manifested in the entire script. It is not necessary to change the whole script. It is important for you to remember that a variable can be either a single character or a group of characters. One good practice is to use a variable that has a description of its function. By doing this, your code will be easier to read, and others can make changes to it without a large amount of difficulty. There are a large number of variables available, and you will want to read the WinRunner manuals to learn more about them.
One WinRunner concept that you will want to become familiar with is the "if/else."As the name implies, it will tell your script to "do this if a certain condition exists, or else, do this." While the if/else option is relatively simple, it will give the developer a large number of advantages. It should also be noted that "if" and "else" do not need to be used in conjunction with one another. For instance, "if" can be used separate from "else." Some scenarios may be easier to handle if you use the two separately. Another thing you will want to become familiar with is arrays. An array will break a string into multiple sections. It is possible for you to use WinRunner to break a string of colors and split them by a comma. Once this is done, the colors can be used in the program, and a field can be assigned to each individual color.
It is easy to see why arrays are so important. They will allow the developer to generate advanced scripts. The Switch is another concept that you will want to become familiar with. A developer may find themselves in a situation where they have certain conditions that are true, and a single block of code will need to be generated for them individually. In this scenario, the developer will want to use a switch statement. The switch statement will remove the need to have various "if" checks. Loops are another important part of WinRunner. They are a necessity for developers that want to work with code that is efficient and easy to maintain.
If you have created an application, and you decide not to use a loop, you may need to manually modify a block of code multiple times. As you can imagine, this would greatly increase the chances of an error occuring. However, by generating a loop that could be used for the multiple blocks of code, things would be much more easier, and the code would have a higher level of efficiency. If you don’t use the loop, the code may have high levels of redundancy. When a loop is used, the code will be easier to read, and it can be maintained without a great deal of effort. The script will also be capable of handling a large number of drivers without needing to have the code altered.
Functions are another important part of WinRunner. If you want to generate powerful functions, you will need to learn how to use them. With a function, code can be reused, and this will reduce the time it will take you to develop and maintain the application. One powerful example of a function is the login function, and it can be utilized by various scripts.