Monday, 6 August 2012

Vbscript level 3



51               Read and display data from CSV file
Program
Set a=createobject("scripting.filesystemobject")
set b=a.opentextfile("F:\test.csv")
  p=1
  While not b.atendofstream
      x=b.readline
      datatable.GetSheet(1).setcurrentrow(p)
      datatable.Value("items",1)=x
      p=p+1
      wend


or
Set a=createobject("scripting.filesystemobject")
set readitems=a.opentextfile("F:\test.csv")
  c=readitems.readall
 print c


52               Display entire data in the web table
a = Browser("Register: Mercury Tours").Page("Welcome: Mercury Tours").WebTable("Atlanta to Las Vegas").RowCount
For i = 1 to a
      b = Browser("Register: Mercury Tours").Page("Welcome: Mercury Tours").WebTable("Atlanta to Las Vegas").GetCellData(i,1)
    c = Browser("Register: Mercury Tours").Page("Welcome: Mercury Tours").WebTable("Atlanta to Las Vegas").GetCellData(i,2)
      print b & "          " &c
Next
Or
s=Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebTable("Atlanta to Las Vegas").GetROProperty("text")
msgbox s
53               Find the background colour of a object

Program

a=Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Link("your destination").getroproperty("background color")
print a        




54               Find screen resolution
Program
a = Window("Program Manager").WinListView("SysListView32").GetROProperty("height")
b = Window("Program Manager").WinListView("SysListView32").GetROProperty("width")
print "The Scree Resolutuion is " & a & " x  " & b

55               Write function to compare two bitmaps

Program

a = Browser("Welcome: Mercury Tours").Page("Sign-on: Mercury Tours").Image("sign-on").GetROProperty("alt")
b = Browser("Welcome: Mercury Tours").Page("Sign-on: Mercury Tours").Image("Register").GetROProperty("alt")
If a = b Then
      print "Both Image Tooltip is Same"
      else
      print "Both Image Tooltip is Not Same"
End If







56               Add and Remove Repositories to the action

a="D:\open.tsr"
b="D:\insert.tsr"
c="D:\delete.tsr"

repositoriescollection.Add(a)
repositoriescollection.Add(b)
repositoriescollection.Add(c)

Window("Flight Reservation").WinObject("Date of Flight:").Type "121212"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt"
Window("Flight Reservation").WinComboBox("Fly To:").Select "London"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "saravanan"
Window("Flight Reservation").WinButton("Insert Order").Click

repositoriescollection.Remove(1)


Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "saravanan"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinButton("OK").Click
57               Load Library files through program
Program
executefile ("D:\msg.vbs")


58               Enable and Disable Recovery scenarios programmatically
Window("Flight Reservation").Activate
Window("Flight Reservation").WinObject("Date of Flight:").Type "111111"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Fr"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "sdf"
Window("Flight Reservation").WinButton("Insert Order").Click
msgbox  "The recovery scenario mech is now:" &" "&Recovery.Enabled
MyCurrentStatus=Recovery.Enabled
If Not( MyCurrentStatus ) Then
Recovery.Enabled=True
End If
Recovery.enabled=False
Window("Flight Reservation").WinButton("Button_5").Click
Window("Flight Reservation").WinObject("Date of Flight:").Type "111111"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Frank"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "sdf"
Window("Flight Reservation").WinButton("Insert Order").Click

59               Report Results status to Results file

Program

reporter.ReportEvent micDone,"test(Object)","Test Report(Details)"

60               Write your own standard checkpoint

Program


Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
Window("Flight Reservation").WinComboBox("Fly To:").Select "London"
b = window("Flight Reservation").Winbutton(a).GetROProperty("Enable")
Window("Flight Reservation").WinButton(a).Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "20260   DEN   08:12 AM   LON   03:23 PM   AA     $112.20"
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
print b

61               Check whether there is a memory leak in the process


62               Close all the dialogs open on a window

Program

s=Window("Flight Reservation").GetROProperty("hwnd")
window("hwnd:="&s).close

(or)

Window("Flight Reservation").close

63               Read menu names and items
Window("Flight Reservation").WinMenu("Menu").ExpandMenu = True
Window("Flight Reservation").Activate
GetNamesRec "", Window("Flight Reservation").WinMenu("Menu")


Function GetNamesRec(itemPath, menuObj)
     ret = 0
     lbl = menuObj.GetItemProperty(itemPath, "Label")
             print lbl     'contains the label such as file, new etc
          ret = menuObj.GetItemProperty(itemPath, "HasSubMenu")
             'print ret  'returns boolean if menu is present
     If ret Then
        cnt = menuObj.GetItemProperty(itemPath, "SubMenuCount")
               ' print cnt  'returns integer value
        For n = 1 To cnt
           Path = menuObj.BuildMenuPath(itemPath, n)
           GetNamesRec Path, menuObj
        Next
    End If
End Function



64               Check whether a check button is selected or not
Program
Window("Flight Reservation").Dialog("Open Order").Activate
status=Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").GetROProperty("checked")
msgbox status


65               Check whether we can select multiple items in the combo box

Program

a = Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("selection")
print a & "is Only Selected in ComboBox Selection"




66               Check whether edit box allows exactly 15 characters

Program



Browser("Register: Mercury Tours").Page("Register: Mercury Tours").Image("mast_register").Click
a = Browser("Register: Mercury Tours").Page("Register: Mercury Tours").WebEdit("firstName").GetROProperty("max length")
If a=15 Then
            print "Edit box allows exactly 15 characters"
            else
            print "Edit box not allows exactly 15 characters"
End If



67               Check whether items in the page are aligned properly

68               Find which add-ins are loaded.
Program

Dim a
Set a=createobject("Quicktest.application")
b=a.getassociatedaddinsfortest("D:\test4")
print "Addins enabled in that test are:"
For each c in b
            print c
    Next



or
TO FIND ADD-IN FOR CURRENT TEST

Dim a
Set a=createobject("Quicktest.application")
b=a.test.getassociatedaddins()
print "Addins enabled in current test are:"
For each c in b
           print c
    Next

69               Check whether a window is in minimized or maximized
Program

a=window("Flight Reservation").GetROProperty("minimizable")
b=window("Flight Reservation").GetROProperty("maximizable")
If a=true Then
print "FR can be minimised"
else
print "FR cannot be minimised"
End If
If b=true Then
print "FR can be maximised"
else
print "FR cannot be maximised"
End If





70               Check window resizable
Program

Window("Microsoft Word").Activate
a = Window("Microsoft Word").GetROProperty("width")
b = Window("Microsoft Word").GetROProperty("height")
a = a - 50
b = b - 50
Window("Microsoft Word").Resize a,b
reporter.ReportEvent micDone,"PASS","Window is Resizable"

71               Check whether logo displayed is correct?

72               Read all items in a tree

Program
a = Window("Local Disk (D:)").WinListView("SysListView32").GetItemsCount
For i = 0 to a-1
            print Window("Local Disk (D:)").WinListView("SysListView32").GetItem(i)
Next



73               Read elements in the XML file

Program

Set a=createobject("msxml2.domdocument")
a.load "D:\test.xml"
set child = a.documentelement.childnodes
childelength =child.length
For i=0 to childelength-1
   x=child.item(i).text
   print x
Next



74               Find font type and size

Program

a = Browser("Register: Mercury Tours").Page("Welcome: Mercury Tours").Link("Business Travel @ About.com").GetROProperty("font")
print a



75               Check Marquee

Program

print browser("Browser").Page("Page").WebElement("Born to Lead the World").GetROProperty("innertext")



76               Check whether selected tab is having different appearance?

77               Check whether a link contains image to its left side.





78               Check whether stock prices are updating an hourly basis

Program

Dim mytime
mytime = now
a = hour(mytime)
print "The Time Now " & a
For i = 1 to 24
      If a = i Then
                  stack = stack + 1000 * i
                  print stack
      End If

Next          

79               Modify Mandatory and Assistive properties programmatically

Program

 

Set app=createobject("QuickTest.Application")

set ident=app.Options.ObjectIdentification

set buttonprop= ident.item("WinButton")

a =buttonprop.MandatoryProperties.Find("text")

print a

buttonprop.MandatoryProperties.Add("y")

a1=buttonprop.MandatoryProperties.Find("y")

print a1

 

'buttonprop.MandatoryProperties.Remove("x")

a2=buttonprop.MandatoryProperties.Find("y")

print a2

 

c = buttonprop.AssistiveProperties.Find("window id")

print c

buttonprop.AssistiveProperties.Add("x")

d = buttonprop.AssistiveProperties.Find("x")

print d



80               Configure Run options programmatically

Program

                  Set a=createobject("QuickTest.Application")
a.options.Run.RunMode="Normal"
a.options.Run.ViewResults="true"
a.options.Run.ImageCaptureForTestResults="OnError"

Before Execution

After Execution

81               Define test results location through program

Program

print browser("Browser").Page("Page").WebElement("Born to Lead the World").GetROProperty("innertext")
reporter.ReportEvent micDone, "Pass","Marquee Captured"
reporter.ReportPath = "D:\"




82               Read and Update data from environmental variable
Program


MsgBox(environment("prak"))
environment("prak") = 20
MsgBox(environment("prak"))


83               Configure maximum timeout value for web page to load
Program
msgbox Environment("value")
Environment("value")=10
msgbox Environment("value")


     



84               Clear the cache in the webpage

webutil.DeleteCookies

85      Instruct Quicktest to Capture Movie Segments of Each Error and Warning                                   
Set a=createobject("QuickTest.Application")
a.options.run.MovieCaptureForTestResults="OnWarning"

VB QUESTIONS


86               Print  arm’s strong number between 1 to 1000.
Program
Dim a, i
For i = 1  to 1000
            If len(i) = 3 Then
                        a = ( i / 100)
                        a = int (a)
                        b = ( i / 10)
                        b = int (b)
                        c = ( b mod 10)
                        c = int (c)
                        d = i mod 10
                        d = int (d)
        j = (a^3) + (c^3) + (d^3)
                        If i = j Then
                                    print i
                        End If
            End If

Next

87               Find whether the given string is Palindrome or not.
Program
MyStr=inputbox("Enter the string:")
reverse=strreverse(MyStr)
s=strcomp(MyStr,reverse)
If s=0 Then
            print "palindrome"
            else
            print "not palindrome"
End If



88               Write a program to Reverse the string.
Program
a = InputBox("Enter the String to Reverse")
b = strreverse(a)
print "Reversed String is " & b



89               Write a program to print the numbers divisible by 3 and 5.
Program
a = int(InputBox("Enter the number to find whether it is Divisible by 3 and 5 "))
If ((a mod 3)= 0) and ((a mod 5)  = 0) Then
Print a & "  is Divisible by 3 & 5"
else
Print a & "  is not Divisible by 3 & 5"
End If


90               Write a program to print the numbers divisible by 7.
Program
For i=1 to 50
            If (i mod 7) =0 Then
                        print i
            End If
Next





91               Print the list of ODD numbers.

Program

print "Odd Number are as follows"
For i=1 to 10
   If (i mod 2) <> 0 Then
                        print i
       End If
Next


92               Print the list of EVEN numbers.
Program
print "Even Number are as follows"
For i=1 to 10
   If (i mod 2) = 0 Then
                        print i
       End If
Next

Output


93               Print the super numbers between 1 t o 1000

Dim a,b,c,d,e,i
For j = 1 to 50
            b = 0
For i = 1 to J-1
            a = J mod i
            If a = 0 Then
                        b = b + i
            End If
Next
If b = J Then
            print J
End If
Next




94               Find number of characters in a given string
Program
a = InputBox("Enter the String")
b = len(a)
print "The Length of the string is " & b


95               Write a program to count only the alphabets.
Program
a=inputbox("Enter a string:")
b =len(str)
c=0
For i=1 to b
            d=asc(mid(a,i,1))
    If d>=65 and d<=90 or d>=97 and d<=122Then
                        c=c+1
            End If
Next
print c


96               Check whether the given number is greater than 100 or not
Program
a = int(InputBox("Enter the Number"))
If a>100 Then
            print a & " is greater than 100"
            else
            print a & " is not greater than 100"
End If


97               Find greatest among two numbers
Program
a = int(InputBox("Enter the First Number"))
b = int(InputBox("Enter the Second Number"))
If a>b Then
            print a & " is greater than "  & b
            else
            print b & " is greater than " & a
End If


98               Find greatest among three numbers
Program
a = int(InputBox("Enter the First Number"))
b = int(InputBox("Enter the Second Number"))
c = int(InputBox("Enter the Third Number"))
If a>b and a>c Then
            print a & " is greater than "  & b & "," & c
            elseif b > a and b > c then
            print b & " is greater than " & a & "," & c
            else
             print c & " is greater than " & a & "," & b
End If

 

99               Write a program to print the Fibonacci series.
Program
a=0
b=1
For i=1 to 10
   t=a+b
   a=b
   b=t
   print t
Next


100           Write a program to find whether the given string is equal or not.
Program


101           Write a program to add two matrix.

Program


Dim A(2,2), B(2,2), C(2,2)
For I = 0 to 2
            For J = 0 to 2
                        A(I,J) = Int(InputBox("Enter the Value of of Array A"))
Next
Next
For I = 0 to 2
            For J = 0 to 2
                        B(I,J) = Int(InputBox("Enter the Value of of Array B"))
Next
Next
For I = 0 to 2
            For J = 0 to 2
                        C(i,j) = A(i,j) + B(i,J)
Next
Next
For I = 0 to 2
            For J = 0 to 2
                        MsgBox C(i,j)
Next
Next

Input


1
2
3
4
5
6
7
8
9
9
8
7
6
5
4
3
2
1




102           Write a program to subtract two matrix.

Program

Dim A(2,2), B(2,2), C(2,2)
For I = 0 to 2
            For J = 0 to 2
            A(I,J) = Int(InputBox("Enter the Value of of Array A"))
Next
Next
For I = 0 to 2
            For J = 0 to 2
            B(I,J) = Int(InputBox("Enter the Value of of Array B"))
Next
Next
For I = 0 to 2
            For J = 0 to 2
            C(i,j) = A(i,j) - B(i,J)
Next
Next
For I = 0 to 2
        For J = 0 to 2
            MsgBox C(i,j)
Next
Next








Input


9
8
7
6
5
4
3
2
1
0
0
1
2
3
4
5
6
7
8
9




103           Write a program to multiply two matrix
Program
Dim A(1,1), B(1,1), C(1,1)
For I = 0 to 1
            For J = 0 to 1
            A(I,J) = Int(InputBox(“Enter the Value of A(”,I,”,”,J,”)”)
Next
Next
For I = 0 to 1
            For J = 0 to 1
            B(I,J) = Int(InputBox(“Enter the Value of B(”,I,”,”,J,”)”)
Next
Next
For I = 0 to 1
For J = 0 to 1
            Sum = 0
            For K = 0 to 0
                        Sum = Sum + A(I,K) + B(K,J)
                        C(I,J) = Sum
            Next
Print C(I,J)
Next
Next

Input

1
1
1
1
1
1
1
1



104    Input to the Function is “Window Name”. The Function should    
          Check Whether the Window exists or not. If exists activate it or else 
          exit.
          Program
Function windowname(wname)
If a="Flight Reservation" Then
            If window("Flight Reservation").Exist  Then
            Window("Flight Reservation").Activate
            else
            MsgBox "Window does not exist"
            End If
End If
End Function
windowname("Flight Reservation")

105    (a.) First take 2 screens, FR and Open Order; In Argument is                                                                                                       
            “Screen Name”.
          (b.) Create 2 shared object repositories (.tsr) for 2 screens that  
             should be same with “screen name.”
          (c.) Based on the screen name, that particular “.tsr” should be   
             loaded.
          Program
          fun = InputBox("Enter the Functionality Name")
Call tp(fun)
Function tp(fun1)
If  fun1 = "Insert Order" Then
repositoriescollection.Add("D:\insert.tsr")
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button_2").Click
Window("Flight Reservation").WinObject("Date of Flight:").Type "111111"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
Window("Flight Reservation").WinComboBox("Fly To:").Select "London"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "20260   DEN   08:12 AM   LON   03:23 PM   AA     $112.20"
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "Prakash"
Window("Flight Reservation").WinButton("Insert Order").Click
repositoriescollection.RemoveAll
else
repositoriescollection.Add("D:\openorder.tsr")
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").WinButton("Button_2").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "5"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
repositoriescollection.RemoveAll
End If
End Function






106    Identify the Total number of Objects in the Object Repository.
          Divide objects into 2 arrays based on Data Entry objects and Non  
          Data Entry objects.
          Program
Set a = CreateObject("Mercury.ObjectRepositoryUtil")
a.load "D:\insert.tsr"
print "All the Objects in the Repositories"
Set z = a.getallobjects(Window)
For k = 0 to z.count-1
Set y = z.item(k)
print a.GetLogicalName(y)
Next
Set z = nothing
Set y = nothing
Set k = nothing
Print "Data Entry Items in Repositories"
dataentry = Array("WinEdit","WinComboBox","WinRadioButton","WinCheckBox","WinList")
For j = 0 to ubound(dataentry)
            Set b = a.getallobjectsbyClass(dataentry(j))
            For i = 0 to b.count-1
                        Set c = b.item(i)
                        d = a.getlogicalname(c)
                        print d
            Next
Set b = nothing
Set c = nothing
Set d = nothing
Set e = nothing
Next

107    From the popup message, get the text only and display the main
          message only.
         
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "55555"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
If Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Exist Then
a = window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Static("Order number [0-9]* does").GetROProperty("text")
print a
End If
Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("OK").Click
Window("Flight Reservation").Dialog("Open Order").WinButton("Cancel").Click



108    From the frame error message, get the text and display only the
          main message.
          Program
a=Browser("Register: Mercury Tours").Page("Register: Mercury Tours").WebElement("Note: The confirmed password").GetROProperty("innertext")
print a

         
109    What is the statement used for comparing 2 strings and print the
          string is equal or not?

          Strcomp is used to compare two string
         
          Program

Dim A, B

A = InputBox("Enter First Name")

B = InputBox("Enter Second Name")

Result  = strcomp(A , B)

If Result = 0 Then

      print "strings are Equal"

      else

      print "strings are Not Equal"

End If



No comments:

Post a Comment