1) Count,
how many Buttons and Edit boxes available in Flight Reservation main window.
SystemUtil.Run
PATH OF THE APPLICATION
     Dialog("Login").Activate
  
Dialog("Login").WinEdit("Agent Name:").Set
"akhilreddy"
    
Dialog("Login").WinEdit("Password:").Set
"mercury"
    Dialog("Login").WinButton("OK").Click
   Set Desc = Description.Create()
    Desc("micclass").Value =
"WinButton"
 Set Buttons = Window("text:=Flight
Reservation").ChildObjects (Desc)
 Num_Buttons = Buttons.Count()
Set
Desc1=Description.Create()
 Desc1("micclass").Value="WinEdit"
 Set Editboxes=Window("text:=Flight
Reservation").ChildObjects (Desc1)
 Num_Editboxes= editboxes.count ()
sum=
Num_Buttons+Num_Editboxes
 Reporter.ReportEvent 2,
"Res","Total Buttons: "& Num_Buttons &"Total
Edit boxes: "& Num_Editboxes
2) Count
all opened Browsers on desktop and close all?
Set Desc =
Description.Create()
    Desc("micclass").Value =
"Browser"
     Set Browsers =Desktop.ChildObjects (Desc)
    NumberofBrowsers = Browsers.Count()
    Reporter.ReportEvent 2,"Res","Number
of Browsers are: "&NumberOfBrowsers
    For Counter=0 to NumberofBrowsers-1
     Browsers(Counter).Close
     Next
3) Create an Excel file, enter some data and save the file through VB
scripting?
Dim objexcel
    Set objExcel = createobject("Excel.application")
    objexcel.Visible = True
     objexcel.Workbooks.add
     objexcel.Cells(1, 1).Value = "akhil
is a good boy"
    
objexcel.ActiveWorkbook.SaveAs("f:\exceltest.xls")
     objexcel.Quit
4) Get Test Data from
a Flat file and use in Data Driven Testing (through Scripting)
Dim
fso,myfile
      Set
fso=createobject("scripting.filesystemobject")
    Set myfile= fso.opentextfile
("f:\anyxl file.xls",1)
      myfile.skipline
      While myfile.atendofline <> True 
      x=myfile.readline
      s=split (x, ",")
      SystemUtil.Run "C:\Program
Files\Mercury Interactive\QuickTest
Professional\samples\flight\app\flight4a.exe"
  Dialog("text:=Login").Activate
Dialog("text:=login","width:=320").winedit("attached
text:= Agent Name:").set"akhil"
Dialog("text:=login").winedit("attachedtext:=password:").setsecure"mercury"
Dialog
("text:=login").winbutton("text:=ok").click
Window("Flight
Reservation").Close
wend
Checking weather the File is available or not, if not creating the
File
strDirectory="E:\"
strFile="aaa.xls"
Set objFSO =
CreateObject("Scripting.FileSystemObject")
If
objFSO.FileExists(strDirectory & strFile) Then
Set objFolder =
objFSO.GetFolder(strDirectory)
Else
Set objFile =
objFSO.CreateTextFile("E:\aaa1.xls")
End if
7) Creating a Flat File
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set
objFile=objFSO.CreateTextFile("E:\akhil.txt")
DELETE A FLAT FILE
Set
objFSO=createobject("Scripting.filesystemobject")
Set txtFilepath =
objFSO.GetFile("E:\AKHIL.txt")
txtFilepath.Delete()
vb script
- VBScript is a scripting language.
 - A scripting language is a lightweight programming language.
 - VBScript is a light version of Microsoft's programming language Visual Basic.
 
2.0 Comments
The comment argument is the
text of any comment we want to include.2.0 Purpose of comments:
o  
We
can use comments for making the script understandable.
o  
We
can use comments for making one or more statements disable from execution.
2.1 Syntax 
Rem comment (After the Rem keyword, a space is required before comment.) 
Or
            Apostrophe (') symbol before the comment
2.2 Comment/Uncomment a block of
statements
- Select block of statement and use short cut key Ctrl + M (for comment)
 - Select comment block and use short cut key Ctrl + Shift + M (for uncomment)
 
VARIABLE: It is a
name given to a memory location, which can hold a value and that can be changed
any number of times in future if required.
Adv:  Reusability & easy to maintain
(future updations are easy) .
 NOTE: always use meaningful names.
Syntax: Datatype variablename;
CONSTANT: It is a
name given to a memory location, which can hold a value that can’t be changed
in future.
Syntax: 
final Datatype constantname=value;             if…. else
CONDITIONAL STATEMENTS :( decision
making statements)
In java we have two types of conditional
statements. 
Switch… case
 among two
blocks then we can use If..Else.
 Syntax: if(condition) {     block
of stmts1       } else { block of stmts2 }
Note : condition is true then block of stmts1
will be executed
Switch…case: Whenever we
want to execute a particular block of statements among many blocks then we will
choose switch case statement.
 Syntax:
switch(choice) {
case “c1”:
 block1
                        break;           
case “c2”:
                        block
2
                        break;
            -----------
            Default:
------ // not mandatory
}
LOOPING STATEMENTS: Looping
statements are used for executing a certain block of statements repeatedly and
continuously for some number of times. 
in java we have 3 types of looping statements 
for loop
while loop
do…while loop
for loop: whenever we
clearly know how many no of times the block should be repeated then use for
loop.
syntax : for(initiation ;condition ;improvement)
            {  
---------------- block of stmts
 }
While loop: It is used
for executing a block of statements repeatedly as long as the condition is
being satisfied.
Syntax: while( condition)  
            {
------- block of stmts
            }
do---- while loop: It is used
for executing a block of statements repeatedly as long as the condition is
being satisfied, but first time execution will be done without checking the
condition. 
Syntax: 
do {
 -------------block of stmts 
}  while(condition) ;
ARRAYS:  Array is a special type of variable which can
hold multiple values. 
in java we have the following types of arrays
single Dimensional array
multi Dimensional array
object array
No comments:
Post a Comment