Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Sunday 31 March 2019

Finding the specified string in Notepad using VB Scripting

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("D:/SAPECC.txt", 1)
line_num = 0
Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
    msgbox( strLine)
    line_num = line_num+1
         If  instr(1,strLine,"Online")<> 0 Then
               MyPos = instr(1,strLine,"Online")
               Msgbox "Line No: " &line_num& " Position: "&MyPos
        EndIf
Loop
objFile.Close
objFSO = nothing
objFile = nothing

Creating Logifle using VB script

Creating a Text File and Appending Texts in the file Using VB Script.


PublicFunction  updateLogsFile(Information,Message)

strLogFilePath = "\\testFramework\Automation\ProjectSAP\FICO\Log File.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
 Time_Stamp = "| " &now& " | " &Information &" | " &Message & " |"

If fso.FileExists(strLogFilePath) Then
    Set ts = fso.Opentextfile(strLogFilePath,8) 
    ts.WriteLine""&Time_Stamp
Else
    Set Text = fso.CreateTextFile(strLogFilePath)
        Text.WriteLine""&Time_Stamp
EndIf

Set ts = Nothing
Set fso = Nothing

EndFunction




Creating Results folder

This function creates a results folder to store Results.

Dim strFolderpath, obj

strFolderpath= "C:\SampleFolder"


Set obj = Createobject("Scripting.FileSystemObject")


If obj.FolderExists(strFolderpath) = false Then
    obj.CreateFolder strFolderpath
End If


Set obj = nothing

Create Report

This  function creates Results file in the results folder and also adds header. Header looks as shown below one.

TestCase Expected Results Actual Results Status
Steps:

Saturday 30 March 2019

Determine How Many Child Objects Match a given Description

'The following example uses the ChildObjects method to retrieve a
set of child objects matching the description listed in the function
call and uses the method to display a message indicating how many
objects are found with the specified description: none, one (unique),
or several (not unique).

Public  Function CheckObjectDesription(parent, descr)

Dim oDesc

' Create description object
Set oDesc = Description.Create()
arProps = Split(descr, ",")
For i = 0 To  UBound(arProps)
arProp = Split(arProps(i), ":=")
    If  UBound(arProp) = 1 Then
      PropName = Trim(arProp(0))
      PropValue = arProp(1)
      oDesc(PropName).Value = PropValue
    End  If 
Next 
' Get all child objects with the given description
Set children = parent.ChildObjects(oDesc)

If children.Count = 1 Then
CheckObjectDesription = "Object Unique" 
ElseIf children.Count = 0 Then
CheckObjectDesription = "Object Not Found" 
Else
CheckObjectDesription = "Object Not Unique" 
End  If 
End  Function 

MsgBox CheckObjectDesription(Window("Flight Reservation"),_
"nativeclass:=Button", "text:=&Insert Order")

MsgBox CheckObjectDesription(Desktop, "nativeclass:=Notepad")

Find Objects on a Web Page and Set a Value

'The following example retrieves the collection of WebEdit objects in order to find a
specific WebEdit object in a page and set a value for it.
 Dim EditToSearch, ValueToSet, NumberOfEdits

'This is the value of the 'name' property for the WebEdit object we want to find.
EditToSearch = "credit_card_number"

ValueToSet = "3558986773230578"
'Create a description object to help retrieve allWebEdit objects in a specific page.
Set oDesc = Description.Create()
    oDesc("micclass").Value = "WebEdit"
    oDesc("name").Value = "credit_card_number" 
'Retrieve all WebEdit objects in this page
Set EditCollection = Browser("Book a Flight: Mercury")_
                    .Page("Book a Flight: Mercury").ChildObjects(oDesc)
NumberOfEdits = EditCollection.Count

'Search for a specific WebEdit object and set its value
For i = 0 To NumberOfEdits - 1
    If EditCollection(i).GetROProperty("name") = EditToSearch Then
       EditCollection(i).Set ValueToSet
    End  If 
Next


Friday 29 March 2019

Find Objects on a Web Page and Save Values in Excel

'The following example retrieves the collection of WebEdit objects that 
contain credit card numbers 'and inserts them in an Excel file.

Dim NumberOfEdits

'Create a Description object to help retrieve all WebEdit objects in a specific page.
Set oDesc = Description.Create()
      'Retrieve all WebEdit objects from this page.
    oDesc("micclass").Value = "WebEdit"
Set EditCollection=Browser("Book a Flight: Mercury")_
                              .Page("Book a Flight: Mercury").ChildObjects(oDesc)
         NumberOfEdits = EditCollection.Count

'Use the GetROProperty to retrieve the "text" property (which in this case 
represents a credit card number) and insert all retrieved credit card numbers 
in an Excel file.

For i = 0 To NumberOfEdits - 1
     CurrentCreditNumber = EditCollection(i).GetROProperty("text")
     WriteToCreditCardNumberExcelFile (CurrentCreditNumber)
Next

Finding All List Objects on a Web Page

'The following example uses the ChildObjects method to find all the list objects 
on a Web page, and then to select an item in each list.

Set oDesc = Description.Create()
    oDesc("micclass").Value = "WebList" 
Set Lists=Browser("Mercury Interactive").Page("Mercury Interactive").ChildObjects(oDesc)
    NumberOfLists = Lists.Count()

For i = 0 To NumberOfLists - 1
    Lists(i).Select i + 1
Next

CheckProperty Method

CheckProperty method Checks whether the actual value of the specified object property matches the specified expected value within the specified timeout.

Syntax-


object.CheckProperty (PropertyName, PropertyValue, [TimeOut])


PropertyName: Required. A String value.

The name of the property whose value is checked. The available properties are listed in the description properties page under each test object.
PropertyValue- Required. A Variant.
The expected value against which the actual property value should be checked. You can either use a simple value or you can use a comparison object together with the value to perform more complex comparisons.
TimeOutOptional. An unsigned long integer value.
The time, in milliseconds, within which UFT should check whether the actual value of the property matches the specified expected value. If no value is specified, UFT uses the time set in the Object Synchronization Timeout option in the Run pane of the Test Settings dialog box.
Default value = 60

Return Type

A Boolean value, Returns TRUE if the property achieves the value, and FALSE if the timeout is reached before the property achieves the value.
A TRUE return value reports a Passed step to the run results; a FALSE return value reports a Failed step to the run results.
NOTE:
If the expected and actual values do not match, an error is reported and the test or component status is changed to failed.
For test run synchronization, or whenever you do not want to fail the test if the expected and actual values do not match, use the WaitProperty method.
Using comparison objects to perform more complex value comparisons.
Using comparison object you can instruct UFT to check whether a specific property value is greater than the specified value.
Syntax:
Object.CheckProperty "items count",micGreaterThan(8)
The following comparison objects can be used:
  • micGreaterThan: Greater than Specifies that UFT checks whether the property value is greater than the specified value.
  • micLessThan: Less than Specifies that UFT checks whether the property value is less than the specified value.
  • micGreaterThanOrEqual: Greater than or equal to Specifies that UFT checks whether the property value is greater than or equal to the specified value.
  • micLessThanOrEqual: Less than or equal to Specifies that UFT checks whether the property value is less than or equal to the specified value.
  • micNotEqual: Not equal to Specifies that UFT checks whether the property value is not equal to the specified value.
  • micRegExpMatch: Regular expression Specifies that UFT checks whether the property value achieves a regular expression match with the specified value. Regular expressions are case-sensitive and must match exactly. 
Note: For example, 'E.*h' matches 'Earth' but not 'The Earth' or 'earth'.


When the types of the expected value and actual value do not match, the comparisons are performed as follows in this below order:
  • Empty values: Empty values may be an uninitialized variable or field (which returns TRUE for the IsNull function in VBscript) or initialized to an empty value (which returns TRUE for the IsEmpty function is VBscript). When trying to compare two arguments when at least one is an empty value, the comparison assumes equality for two uninitialized arguments and for two empty arguments. Any other combination is considered unequal.
Example:

dim vEmpty
Object.CheckProperty "text",micNotEqual(vEmpty)
 

will not wait for the timeout (because the 'text' property value is an empty string and the argument passed to micNotEqual is an empty value, and so micNotEqual finds them not equal and returns TRUE).

  • String values: When trying to compare a string value with non-string value, the string value is converted to the non-string type and then compared. If the string value cannot be converted to the non-string type, the comparison assumes the values are not equal.
Example:

Object.CheckProperty "text",micGreaterThan(8) 

will not wait for the timeout if the 'text' property value is '16' (because micGreaterThan finds 16 to be greater than 8 and returns TRUE), but will wait if the 'text' property value is 'a' (because 'a' cannot be converted to a number).
  • Boolean values: When trying to compare a Boolean value with non-boolean value, the non-boolean value is converted to a boolean value and then compared. The conversion method assumes that any integer value other than '0' is TRUE, and that '0' alone is FALSE. If the conversion fails to produce a boolean value (for example, if the value is 'abc'), the comparison result will be FALSE (note that for the WaitProperty method this result would instruct UFT to keep waiting). If the conversion succeeds, the method compares the two boolean values according to the comparison logic.
  • Other value types: When other value types do not match, they are compared under the assumption that different types are not equal (nor greater than or less than each other).
Note: When working with Mobile objects, you can use this method only for a limited list of properties.
Examples:
1...Check Whether the Text is Entered in an Edit Box..... ?
'The following example uses the CheckProperty method to check whether
'the text "Mercury" is entered in the "Name" edit box.
 
Browser("Nested Lists").Page("Page").WebEdit("Name").Set "Mercury"
Browser("Nested Lists").Page("Page").WebEdit("Name")
.CheckProperty"value","Mercury"

2... Verify the Number of Items in a List..... ?

'The following example uses the CheckProperty method to verify the number of items in a WebList. Note that if the original count is not equal to 15, an error message is displayed in the run results.
Browser("Fill-Out Form Example").Page("Fill-Out Form Example")
.WebList("what-to-do").CheckProperty "items count", 15, TimeLimitation
Item_Count = Browser("Fill-Out Form Example").Page("Fill-Out Form Example")
.WebList("what-to-do").GetROProperty("items count")

If Item_Count = 15 Then 'Remove one item from the list
    Browser("Fill-Out Form Example").Page("Fill-Out Form Example")
   .WebButton("Remove Item From List").Click
    'Check if the item was removed from the list
    Browser("Fill-Out Form Example").Page("Fill-Out Form Example")
   .WebList("what-to-do").CheckProperty "items count", 14, TimeLimitation
Else
    Reporter.ReportEvent micFail,"Number Of List Items",\
                 "The item count in the list should be 15, not " & Item_Count & "." 
End  If

WebTabStrip Object


A tab strip control in a Web page or application.

Common Method CaptureBitmapSaves a screen capture of the object as a .png or .bmp image, depending on the specified file extension.
Common Method CheckChecks whether the actual value of an item matches the expected value.
Common Method CheckPropertyChecks whether the specified object property achieves the specified value within the specified timeout.
Common Method ChildObjectsReturns the collection of child objects contained within the object.
Method ClickClicks the object.
Method DoubleClickClicks on the object twice.
Method DragPerforms the 'drag' part of a drag and drop operation.
Method DropPerforms the 'drop' part of a drag and drop operation.
Method FireEventTriggers an event.
Common Method GetROPropertyReturns the current value of the specified description properties from the object in the application.
Common Method GetTOPropertiesReturns the collection of properties and values used to identify the object.
Common Method GetTOPropertyReturns the value of the specified description properties from the test object description.
Method HoverTapWhen hover is supported, places the pointer on the object. Otherwise, taps the object.
Method LongPressPresses and holds the object.
Method MiddleClickMiddle-clicks the object.
Common Method OutputRetrieves the current value of an item and stores it in a specified location.
Method PanPerform a pan gesture.
Method PinchPerform a pinch gesture.
Common Method RefreshObjectInstructs UFT to re-identify the object in the application the next time a step refers to this object.
Method RightClickRight-clicks the object.
Method SelectSelect the Tab.
Common Method SetTOPropertySets the value of the specified description properties in the test object description.
Method SubmitSubmits a form.
Method SwipeSwipes the object.
Common Method ToStringReturns a string that represents the current test object.
Common Method WaitPropertyWaits until the specified object property achieves the specified value or exceeds the specified timeout before continuing to the next step.



Thursday 28 March 2019

Testing Methodologies

Software testing methodologies are the various strategies or approaches used to test an application to ensure it behaves and looks as expected. These encompass everything from front to back-end testing, including unit and system testing.



Monday 18 March 2019

SD n MM Process



MM Flow:

  • The process begins with planning what materials are required, when they are required, and the price that the company can afford to pay for them.
  • Then the company prepares a list of vendors that they think can provide the materials for them.
  • The company asks each of the vendors to submit a quotation, which includes the price, terms of delivery, quality of materials, and any other information that they need for making their decision. This stage could also involve negotiating with the vendors for the best deal.
  • Once a vendor has been chosen, the buyers create a purchase requisition form that includes information such as the description of goods and services, department account number, signatures of the authorized managers, delivery instructions and quotation from the authorized vendor.
  • A formal purchase order is sent to the vendor to supply the goods along with instructions as to the conditions under which they have to be supplied.
  • Once the company receives the goods from the supplier, the purchase department prepares a Goods Receipt. This is an important document which can later be used for reconciling if what the seller delivered was indeed what they asked for.
  • The Goods Receipt is compared with the Purchase Order to validate if the two match. If there are any discrepancies, the buyer can contact the seller and post a complaint. Checks are made if the goods are suitable for use or not, if the correct quantity has been delivered, if all the goods meet the ordered specifications, and they are priced according to the terms of the purchase order. If any goods are damaged then the buyers will have to contact the sellers and ask either for a replacement or a refund.
  • Once the verification of the goods is done, the payment invoice is created and the necessary approvals from the project managers are obtained.

  • When the company makes the final payments to the vendor, the cycle comes to a close.
Procure to Pay Cycle

1. Purchase Re-question- ME51 (Requirement Planning)
2. Request for Quotation- ME41
3. Quotation from different vendors- ME47
4. Price comparison- ME49
5. Purchase order send to vendors- ME22
6. Goods receipts- MIGO
7. logistic invoice verification- MIRO
8. Vendor Payment- FB60
9. Receipt of Money- FB50 
SD Flow:
Order-to-Cash is an integration point between Finance (FI) and Sales (SD). It is a business process that involves sales order from customers to delivery and invoice. It comprises SO, Delivery, Post Goods Issue (PGI) and billing to customers. Its configuration touches both Finance and Sales & Distribution modules. The process starts when a customer inquires for an inventory item (finished goods for a company). The customer gets quote for the item and place an order for the quantity needed. A user from company place the order and pass it for processing. Inventory gets picked up from warehouse and shipped to customer. Billing process also starts with delivery and it can be sent with the item or later. 

This process gives integration between customer master record, sales organization, sales offices, distribution channels, divisions and plants.
1. Inquiry -VA11
2. Quotation - VA21
3. Sales Order Creation - VA01
4. Post Goods Issue(PGI) - VL01n
5. Delivery - VL01n
6. Billing - VF01
7. Receipt of Money - FB50 


Note:



Thursday 7 March 2019


How to read registry key in UFT......?

'Create a shell object
Set WshShell = CreateObject("WScript.Shell")

'Read the value of key from the registry
bvalue = WshShell.RegRead(varpathofkey)

'in above function we have to pass the path of key in registery.
e.g. HKCU\Software\ie\settings

msgbox bvalue


How to read/write a value in the registry key....?

In some scenarios for troubleshooting/workarounds it is requested to modify the value of a registry key. If this modification is necessary to be perform in more than one machine.

Dim WshShell
Set WshShell = CreateObject("WScript.Shell")

WshShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\Packages\WebPackage\Settings\IgnoreHiddenFrames", 1, "REG_DWORD"


Nothing = WshShell

Note:
Where "IgnoreHiddenFrames" is the key to modify. The value to write is "1" and the type is "Dword"

Example: 

in case you need to read the value, before modifying it. 

Dim WshShell
Set WshShell = CreateObject("WScript.Shell")

WshShell.RegRead "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\Packages\WebPackage\Settings\IgnoreHiddenFrames"

Nothing = WshShell

Saturday 2 March 2019

WebTable methods in UFT/QTP

UFT/QTP helps to identify by providing Web table class. WebTable class provides various methods to work on web table. Webtable class contains various methods which allows to work on tabular structure.Tables inside web pages are implemented without any name or id attributes most of the times. This makes it difficult for Automation engineer to create robust scripts for identifying the Table correctly at run-time. Below are explained webtable methods with examples.

1. Exist 
2. RowCount
3. ColumnCount
4. GetCellData
5. GetRowWithCellText
6. ChildItem
7. ChildItemCount
8. ChildObject

Exist
Description: Exist method is used to check whether the webtable is exist in the open application or not.
Syntax: Obj.Exist                                           
Return Type: A Boolean Value
Example:

Dim Var
Var = Browser(“Name:=Browser”).Page(“Title:=Page”).WebTable(“Name:=WebTable”).Exist
Msgbox Var 

RowCount
Description: RowCount method is used to get the number of rows in the webtable.
Syntax: Obj.RowCount                                  
Return Type: Long
Example:

Dim Row_Count
Row_Count = Browser(“Name:=Browser”).Page(“Title:=Page”).WebTable(“Name:=WebTable”).RowCount
Msgbox Row_Count

ColumnCount
Description: ColumnCount method is used to get the number of Columns in the webtable.
Syntax: Obj.ColumnCount(Row)                   
Return Type: Long
Example:

Dim Column_Count
Column_Count = Browser(“Name:=Browser”).Page(“Title:=Page”).WebTable(“Name:=WebTable”). ColumnCount(Row)
Msgbox Column_Count  

GetCellData
Description: GetCellData method is used to get the Text/Value contained in the specified cell in the webtable.
Syntax: Obj.GetCellData(Row,Column)       
Return Type: String
Example: 

Dim Var_Data
Var_Data = Browser(“Name:=Browser”).Page(“Title:=Page”).WebTable(“Name:=WebTable”). GetCellData(Row_Num, Column_Num)
Msgbox Var_Data   

GetRowWithCellText
Description: GetRowwithCellText method is used to get the number of first row found that contains a cell with the specified text in the webtable.
Syntax: Obj.GetRowwithCellText(Text, Column(Optional), StartFromRow (Optional))  
Return Type: Long
Example

Dim Row_Num
Row_Num = Browser(“Name:=Browser”).Page(“Title:=Page”).WebTable(“Name:=WebTable”). GetRowWithCellText(Row_Num, Column_Num)
Msgbox Row_Num

ChildItem
Description: ChildItem method is used when we want to get a test object from the cell in a webtable by type and index.
Syntax: Obj.ChildItem(Row, Column, MicClass, Index)         
Return Type: An Obeject
Example

Dim ObjObject
ObjObject = Browser(“Name:=Browser”).Page(“Title:=Page”).WebTable(“Name:=WebTable”).ChildItem(2,1,”WebCheckbox”, 1)

ChildItemCount
Description: ChildItemCount method is used when we want to get the number of objects of a specified Type in the specified cell in webtable.
Syntax: Obj.ChildItemCount(Row, Column, MicClass)          
Return Type: A Long Value
Example

Dim VarCount
VarCount = Browser(“Name:=Browser”).Page(“Title:=Page”).WebTable(“Name:=WebTable”).ChildItemCount(2,1,”WebCheckbox”)

ChildObjects
Description: ChildIObjects method is used when we want to get the number of child objects of a specified Type in the webtable.
Syntax: Obj.ChildObject(“MicClass”)           
Return Type: A collection of Objects
Example

Set Obj = Description.Create
     Obj("micclass").value = "Link"
Set  ObjChild = Browser("Name:=Page").Page("Title:=Page").WebTable("Name:=WebTable").ChildObjects(Obj)
For i = 0  to  ObjChild.count-1
MsgBox Obj1(i).GetROProperty("Name")

Next