QTP VB Script Trainings

40,061 views

Published on

VB Script Training Sessions

Published in: Technology, Business
5 Comments
13 Likes
Statistics
Notes
  • Hi i'm beginner to QTP. can anyone tell me which book is good to learn QTP and its scripting.??
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Hi,



    Technology Specific Guide for QTP is a new book that has got great feedback from all the readers. It will get you started on the path of automation, introducing solutions, roadblocks, patches and ideas that will give you a solid foundation in the field of automation. Everyone from a novice user to an automation expert will have something they would have never heard of or used.



    http://bluemagic-automation.blogspot.in/



    Best Regards,

    Aditya.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Nice presentation...

    You can also check the below link for more turotials on QTP and VBScript.

    http://www.automationrepository.com/category/qtp-and-vbscript-tutorials/
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • thanks
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • thanks
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
40,061
On SlideShare
0
From Embeds
0
Number of Embeds
2,094
Actions
Shares
0
Downloads
1,777
Comments
5
Likes
13
Embeds 0
No embeds

No notes for slide
  • QTP VB Script Trainings

    1. 1. VB Script <ul><li>By: </li></ul><ul><li>Ali Imran Khan </li></ul><ul><li>[email_address] </li></ul>
    2. 2. <ul><li>VBScript is a scripting language </li></ul><ul><li>Scripting language is a lightweight programming language </li></ul><ul><li>VBScript is a light version of Microsoft's programming language Visual Basic </li></ul><ul><li>VBScript can be used for both client-side and server-side programming. </li></ul>
    3. 3. VBScript Variables <ul><ul><li>A variable is a &quot;container&quot; for information you want to store. </li></ul></ul><ul><ul><li>Naming Rules : </li></ul></ul><ul><ul><ul><li>Must begin with an alphabetic character </li></ul></ul></ul><ul><ul><ul><li>Cannot contain a period </li></ul></ul></ul><ul><ul><ul><li>Cannot exceed 255 characters </li></ul></ul></ul><ul><ul><ul><li>Must be unique within its scope </li></ul></ul></ul>
    4. 4. Lifetime OF Variables <ul><ul><li>Local Variables: </li></ul></ul><ul><li>When you declare a variable within a procedure, the variable can only be accessed within that procedure. When the procedure exits, the variable is destroyed. You can have local variables with the same name in different procedures, because each is recognized only by the procedure in which it is declared. </li></ul><ul><ul><li>Global Variables: </li></ul></ul><ul><li>If you declare a variable outside a procedure, all the procedures on your page can access it. The lifetime of these variables starts when they are declared, and ends when the script is closed. </li></ul>
    5. 5. Variable (Cont) <ul><li>Declaration: </li></ul><ul><ul><li>Dim Keyword is used to Declare a variable </li></ul></ul><ul><ul><li>You can Assign a Value to variable directly (without declaring a variable). But not a good practice. </li></ul></ul><ul><ul><li>Option Explicit Keyword is used to restrict variables to be declared before their usage. </li></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><ul><ul><li>Option explicit </li></ul></ul></ul><ul><ul><ul><li>Dim var_ x </li></ul></ul></ul><ul><ul><ul><li>var_x=1 </li></ul></ul></ul>
    6. 6. Constants <ul><li>Const keyword is used to declare constants. </li></ul><ul><li>It is necessary to initialize the Constant during its declaration. </li></ul><ul><li>You cannot change the value of constants in later script. </li></ul><ul><li>Syntax: </li></ul><ul><li>const x=1 </li></ul>
    7. 7. <ul><li>Practical Work ! </li></ul>
    8. 8. Arrays <ul><li>An array is a set of variables conveniently packages for easy handling </li></ul><ul><li>Sometimes you want to assign more than one value to a single variable. Then you can create a variable that can contain a series of values. This is called an array variable </li></ul>
    9. 9. Arrays (cont.) <ul><li>The declaration of an array variable uses parentheses ( ) following the variable name. </li></ul><ul><li>Example: </li></ul><ul><li>dim names(2) </li></ul><ul><li>names(0)=“Ali“ </li></ul><ul><li>names(1)=“Imran“ </li></ul><ul><li>names(2)=“Khan&quot; </li></ul>
    10. 10. Arrays (cont.) <ul><li>An array can be multi dimensional. </li></ul><ul><li>There can be 60 (maximum) dimensions in an array. </li></ul><ul><li>Multiple dimensions are declared by separating the numbers in the parentheses with commas. </li></ul>
    11. 11. Practical Work !
    12. 12. Procedures <ul><li>A Sub procedure: </li></ul><ul><li>is a series of statements, enclosed by the Sub and End Sub statements </li></ul><ul><li>can perform actions, but does not return a value </li></ul><ul><li>can take arguments that are passed to it by a calling procedure </li></ul><ul><li>without arguments, must include an empty set of parentheses () </li></ul>
    13. 13. Procedures (Cont) <ul><li>Sub Keyword is Used to declare a procedure. </li></ul><ul><li>End Sub Keyword is Used to defining the ending boundary of a procedure. </li></ul><ul><li>Call Keyword is Used in order to invoke a procedure. </li></ul><ul><li>Syntax: </li></ul><ul><li>Sub mysub() </li></ul><ul><li>some statements </li></ul><ul><li>End Sub </li></ul><ul><li>Call mysub() </li></ul>
    14. 14. Procedures (Cont) <ul><li>Procedure can take arguments that are passed to it by calling that procedure . </li></ul><ul><li>Syntax: </li></ul><ul><li>Sub procedure name(arg1,arg2) </li></ul><ul><li>some statements </li></ul><ul><li>End Sub </li></ul><ul><li>Call mysub(value1,value2) </li></ul>
    15. 15. Practical Work !
    16. 16. Functions <ul><li>A Function procedure: </li></ul><ul><li>is a series of statements, enclosed by the Function and End Function statements </li></ul><ul><li>can perform actions and can return a value </li></ul><ul><li>can take arguments that are passed to it by a calling procedure </li></ul><ul><li>without arguments, must include an empty set of parentheses () </li></ul><ul><li>returns a value by assigning a value to its name </li></ul>
    17. 17. Functions (Cont) <ul><li>Function Keyword is Used to declare a Function. </li></ul><ul><li>End Function Keyword is Used to defining the ending boundary of a Function. </li></ul><ul><li><Function Name> is Used in order to invoke a Function. </li></ul><ul><li>Syntax: </li></ul><ul><li>Function myfunc() </li></ul><ul><li>some statements </li></ul><ul><li>End Function </li></ul><ul><li>myfunc </li></ul>
    18. 18. Practical Work !
    19. 19. If Condition <ul><li>If keyword is used for executing a set of code when certain condition is true. </li></ul><ul><li>Endif keyword is used to end the if condition code block. </li></ul><ul><li>Syntax: </li></ul><ul><li>If <condition> then </li></ul><ul><li>Some statements </li></ul><ul><li>End if </li></ul>
    20. 20. If-Else Condition <ul><li>if...then...else - use this keyword if you want to select one of two sets of lines to execute </li></ul><ul><li>if...then...elseif - use this keyword if you want to select one of many sets of lines to execute </li></ul>
    21. 21. If-Else Condition (cont.) <ul><li>Syntax : </li></ul><ul><li>if <condition> then </li></ul><ul><li>Some statements </li></ul><ul><li>Else </li></ul><ul><li>Some statements </li></ul><ul><li>end If </li></ul>
    22. 22. If-Elseif Condition (cont.) <ul><li>Syntax : </li></ul><ul><li>if <condition> then </li></ul><ul><li>Some statements </li></ul><ul><li>Elseif <condition> then </li></ul><ul><li>Some statements </li></ul><ul><li>Else </li></ul><ul><li>Some statements </li></ul><ul><li>end If </li></ul>
    23. 23. Practical Work !
    24. 24. Select Case Condition <ul><li>Select case keyword is used to execute one of many blocks of code. </li></ul><ul><li>Syntax </li></ul><ul><li>select case <variable> </li></ul><ul><li>case <first expected value> </li></ul><ul><ul><li>Some statements </li></ul></ul><ul><li>case <second expected value> </li></ul><ul><ul><li>Some statements </li></ul></ul><ul><ul><li>……… </li></ul></ul><ul><ul><li>……… </li></ul></ul><ul><ul><li>case Else </li></ul></ul><ul><ul><li>Some Statements </li></ul></ul><ul><ul><li>end select </li></ul></ul>
    25. 25. Practical Work !
    26. 26. For Loop <ul><li>For loop is used to execute set of statements , pre defined number of iterations. </li></ul><ul><li>For … Next keywords are used to implement the For Loop. </li></ul><ul><li>Syntax: </li></ul><ul><li>For <Loop initialization state> to <ending condition> </li></ul><ul><ul><li>Some Statements </li></ul></ul><ul><li>Next </li></ul>
    27. 27. For Loop (cont.) <ul><li>Step keyword is used to increase or decrease the counter variable by the specified value. </li></ul><ul><li>Syntax </li></ul><ul><li>For <Loop initialization state> To <ending condition> Step <Increment/Decrement value> </li></ul><ul><li>some statements </li></ul><ul><li>Next </li></ul>
    28. 28. For Loop (cont.) <ul><li>You can use for loop in order to repeat a block of code for each item in a collection, or for each element of an array. </li></ul><ul><li>Syntax: </li></ul><ul><li>For Each <variable name > in <array Variable Name> </li></ul><ul><ul><ul><li><Some Statements> </li></ul></ul></ul><ul><ul><ul><li>Next </li></ul></ul></ul>
    29. 29. Practical Work !
    30. 30. Do-while loop <ul><li>Do-while keywords are used to execute specified code for a set of times (until a condition remains true or a condition becomes false). </li></ul><ul><li>Syntax </li></ul><ul><ul><li>Do While <Condition for loop> </li></ul></ul><ul><ul><ul><li>Some Statements </li></ul></ul></ul><ul><ul><li>Loop </li></ul></ul>
    31. 31. Do-while loop (cont.) <ul><li>Do-While can also used in following syntax: </li></ul><ul><li>Do </li></ul><ul><li>some Statements </li></ul><ul><li>Loop While i>10 </li></ul>
    32. 32. Do-Until Loop <ul><li>Do – Until keyword is used for repeating some set of statements until a certain condition is true. </li></ul><ul><li>Syntax: </li></ul><ul><li>Do Until <Condition> </li></ul><ul><ul><li>some statmemts </li></ul></ul><ul><li>Loop </li></ul>
    33. 33. Do-Until Loop (cont.) <ul><li>Do-Until can also used in following syntax: </li></ul><ul><li>Do </li></ul><ul><li>some statements </li></ul><ul><li>Loop Until <Condition> </li></ul>
    34. 34. Practical Work !
    35. 35. Built in Functions <ul><li>VB Script provides several built in functions that can be used just by calling them. </li></ul><ul><li>Few Examples: </li></ul><ul><li>Date </li></ul><ul><li>Time </li></ul><ul><li>Int </li></ul>
    36. 36. Practical Work !
    37. 37. Thank You !

    ×