Search here for all the info you want in this Blog

Showing posts with label interview questions. Show all posts
Showing posts with label interview questions. Show all posts

Descriptive Programming (DP) vs Object Repository (OR)

if you ask the difference between object repository and descriptive programming or advantages and disadvantages of both.

everybody will see it in their own view, both has its own advantages and disadvantages

 Object Repository:

    QTP identifies the test object properties which it learns while recording and stores the object properties in the object repository.QTP will use these stored properties while executing the recorded script.

Descriptive programming : this a script method where object properties are directly coded  instead of storing it object repository.
There are two types :
  
   * creating decription object using create.description()
   *You list the set of properties and values that describe the object directly in a     
       VBScript statement

 Advantages of DP over object repository:
 
 a) It is tedious to maintain the object repository, when the size increases.
 b) We have to cautious will using shared repository, if any changes made it will 
     affect  all the tests associated with it.
 c) OR will be time consuming to maintain.





How To Create and Save a Word Document in VBScript


Set objWord = CreateObject("Word.Application")
objWord.Caption = "Test Caption"
objWord.Visible = True

Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

objSelection.Font.Name = "Arial"
objSelection.Font.Size = "18"
objSelection.TypeText "Network Adapter Report"
objSelection.TypeParagraph()

objSelection.Font.Size = "14"
objSelection.TypeText "" & Date()
objSelection.TypeParagraph()
objSelection.TypeParagraph()

objSelection.Font.Size = "10"

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration")

For Each objItem in colItems

    objSelection.Font.Bold = True
    objSelection.TypeText "ARP Always Source Route: "
    objSelection.Font.Bold = False
    objSelection.TypeText "" & objItem.ArpAlwaysSourceRoute
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "ARP Use EtherSNAP: "
    objSelection.Font.Bold = False
    objSelection.TypeText ""  & objItem.ArpUseEtherSNAP
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "Caption: "
    objSelection.Font.Bold = False
    objSelection.TypeText ""  & objItem.Caption
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "Database Path: "
    objSelection.Font.Bold = False
    objSelection.TypeText ""   & objItem.DatabasePath
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "Dead GW Detection Enabled: "
    objSelection.Font.Bold = False
    objSelection.TypeText ""   & objItem.DeadGWDetectEnabled
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "Default IP Gateway: "
    objSelection.Font.Bold = False
    objSelection.TypeText "" & objItem.DefaultIPGateway
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "Default TOS: "
    objSelection.Font.Bold = False
    objSelection.TypeText ""  & objItem.DefaultTOS
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "Default TTL: "
    objSelection.Font.Bold = False
    objSelection.TypeText ""  & objItem.DefaultTTL
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "Description: "
    objSelection.Font.Bold = True
    objSelection.Font.Bold = False
    objSelection.TypeText ""  & objItem.Description
    objSelection.TypeParagraph()

    objSelection.TypeParagraph()

Next

objDoc.SaveAs("C:\Scripts\Word\testdoc.doc")
objWord.Quit

How to Create a New Word Document


Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()

How to Get the List Of Microsoft Word Document Properties


On Error Resume Next

Set objWord = CreateObject("Word.Application")
Wscript.Echo "Active Printer:", objWord.ActivePrinter

For Each objAddIn in objWord.AddIns
    Wscript.Echo "AddIn: ", objAddIn
Next

Wscript.Echo "Application:", objWord.Application
Wscript.Echo "Assistant:", objWord.Assistant

For Each objCaption in objWord.AutoCaptions
    Wscript.Echo "AutoCaptions:", objCaption
Next
Wscript.Echo "Automation Security:", objWord.AutomationSecurity
Wscript.Echo "Background Printing Status:", objWord.BackgroundPrintingStatus
Wscript.Echo "Background Saving Status:", objWord.BackgroundSavingStatus
Wscript.Echo "Browse Extra File Type:", objWord.BrowseExtraFileTypes
Wscript.Echo "Build:", objWord.Build
Wscript.Echo "Caps Lock:", objWord.CapsLock
Wscript.Echo "Caption:", objWord.Caption

For Each objLabel in objWord.CaptionLabels
    Wscript.Echo "Caption Label:", objLabel
Next

Wscript.Echo "Check Language:", objWord.CheckLanguage

For Each objAddIn in objWord.COMAddIns
    Wscript.Echo "COM AddIn:", objAddIn
Next

Wscript.Echo "Creator:", objWord.Creator

For Each objDictionary in objWord.CustomDictionaries
    Wscript.Echo "Custom Dictionary:", objDictionary
Next

Wscript.Echo "Customization Context:", objWord.CustomizationContext
Wscript.Echo "Default Legal Blackline:", objWord.DefaultLegalBlackline
Wscript.Echo "Default Save Format:", objWord.DefaultSaveFormat
Wscript.Echo "Default Table Separator:", objWord.DefaultTableSeparator

For Each objDialog in objWord.Dialogs
    Wscript.Echo "Dialog:", objDialog
Next

Wscript.Echo "Display Alerts:", objWord.DisplayAlerts
Wscript.Echo "Display Recent Files:", objWord.DisplayRecentFiles
Wscript.Echo "Display Screen Tips:", objWord.DisplayScreenTips
Wscript.Echo "Display Scroll Bars:", objWord.DisplayScrollBars

For Each objDocument in objWord.Documents
    Wscript.Echo "Document:", objDocument
Next

Wscript.Echo "Email Template:", objWord.EmailTemplate
Wscript.Echo "Enable Cancel Key:", objWord.EnableCancelKey
Wscript.Echo "Feature Install:", objWord.FeatureInstall

For Each objConverter in objWord.FileConverters
    Wscript.Echo "File Converter:", objConverter
Next

Wscript.Echo "Focus In MailHeader:", objWord.FocusInMailHeader

For Each objFont in objWord.FontNames
    Wscript.Echo "Font Name:", objFont
Next

Wscript.Echo "Height", objWord.Height

For Each objBinding in objWord.KeyBindings
    Wscript.Echo "Key Binding:", objBinding
Next

For Each objFont in objWord.LandscapeFontNames
    Wscript.Echo "Landscape Font Name:", objFont
Next

Wscript.Echo "Language", objWord.Language

For Each objLanguage in objWord.Languages
    Wscript.Echo "Language:", objLanguage
Next

Wscript.Echo "Left", objWord.Left
Wscript.Echo "Mail System:", objWord.MailSystem
Wscript.Echo "MAPI Available:", objWord.MAPIAvailable
Wscript.Echo "Math Coprocessor Available:", objWord.MathCoprocessorAvailable
Wscript.Echo "Mouse Available:", objWord.MouseAvailable
Wscript.Echo "Name:", objWord.Name
Wscript.Echo "Normal Template:", objWord.NormalTemplate
Wscript.Echo "Num Lock:", objWord.NumLock
Wscript.Echo "Parent:", objWord.Parent
Wscript.Echo "Path:", objWord.Path
Wscript.Echo "Path Separator:", objWord.PathSeparator
Wscript.Echo "Print Preview:", objWord.PrintPreview

For Each objFile in objWord.RecentFiles
    Wscript.Echo "Recent File:", objFile
Next

Wscript.Echo "Screen Updating:", objWord.ScreenUpdating
Wscript.Echo "Show Visual Basic Editor:", objWord.ShowVisualBasicEditor
Wscript.Echo "Special Mode:", objWord.SpecialMode
Wscript.Echo "Startup Path:", objWord.StartupPath

For Each objTask in objWord.Tasks
    Wscript.Echo "Task:", objTask
Next

For Each objTemplate in objWord.Templates
    Wscript.Echo "Template:", objTemplate
Next

Wscript.Echo "Top:", objWord.Top
Wscript.Echo "Usable Height:", objWord.UsableHeight
Wscript.Echo "Usable Width:", objWord.UsableWidth
Wscript.Echo "User Address:", objWord.UserAddress
Wscript.Echo "User Control:", objWord.UserControl
Wscript.Echo "User Initials:", objWord.UserInitials
Wscript.Echo "User Name:", objWord.UserName
Wscript.Echo "Version:", objWord.Version
Wscript.Echo "Visible:", objWord.Visible
Wscript.Echo "Width:", objWord.Width

For Each objWindow in objWord.Windows
    Wscript.Echo "Window:", objWindow
Next

Wscript.Echo "Window State:", objWord.WindowState
objWord.Quit

How to Read an Excel Spreadsheet in VBScript


Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
    ("C:\Scripts\New_users.xls")

intRow = 2

Do Until objExcel.Cells(intRow,1).Value = ""
    Wscript.Echo "CN: " & objExcel.Cells(intRow, 1).Value
    Wscript.Echo "sAMAccountName: " & objExcel.Cells(intRow, 2).Value
    Wscript.Echo "GivenName: " & objExcel.Cells(intRow, 3).Value
    Wscript.Echo "LastName: " & objExcel.Cells(intRow, 4).Value
    intRow = intRow + 1
Loop

objExcel.Quit

How To Format a Range of Cells in Excel sheet


Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True
objExcel.Workbooks.Add

objExcel.Cells(1, 1).Value = "Name"
objExcel.Cells(1, 1).Font.Bold = TRUE
objExcel.Cells(1, 1).Interior.ColorIndex = 30
objExcel.Cells(1, 1).Font.ColorIndex = 2
objExcel.Cells(2, 1).Value = "Test value 1"
objExcel.Cells(3, 1).Value = "Test value 2"
objExcel.Cells(4, 1).Value = "Tets value 3"
objExcel.Cells(5, 1).Value = "Test value 4"

Set objRange = objExcel.Range("A1","A5")
objRange.Font.Size = 14

Set objRange = objExcel.Range("A2","A5")
objRange.Interior.ColorIndex = 36

Set objRange = objExcel.ActiveCell.EntireColumn
objRange.AutoFit()

How To Add Formatted Data to a Spreadsheet


Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True
objExcel.Workbooks.Add
objExcel.Cells(1, 1).Value = "Test value"
objExcel.Cells(1, 1).Font.Bold = TRUE
objExcel.Cells(1, 1).Font.Size = 24
objExcel.Cells(1, 1).Font.ColorIndex = 3