Saturday 22 February 2014

Basic Required Method in TestComplete - Part 2



I have explain few basic method in my previous blog Basic Required method - part 1. Now I am adding few more method in this blog, have enjoy it !!

1 - ContentText :- ContentText method is used to get the text from the TestedObj, it returns the combination of text from the
TestedObj. Suppose you want to get text from google page (eg. "Google") at that time we can use this property.
Syntax -

       getText = TestObject.ContentText                                                                    

2- InnerText :- InnerText is used to get the text from the TestedObj, it also returns the combination of text from the TestedObj.  
Syntax -
     
       getText = TestObject.innerText                                                                        

Note : - innerText is similar to contentText, but it is an extended property of Internet Explorer browser. Hence do not use this property in your test it's may get fail if you are moving for cross browser test.

3- Find : - This method is used to search the object from the
TestedObj hierarchy.This method searches an object with the specified values of the specified properties. here search starts from TestedObj parent node and continue upto the depth mention.
Syntax
     
       Set myObject = TestObject.Find(PropertyName, PropertyValue, Depth)        

Example - Suppose I want to search "gmail link" on google page, So I will write code as below

Set lnkgmail = Sys.Browser("IExplorer").Page("google.com").Find("ContentText", "gmail", 10) 

Here - 
1- Property Name = ContentText
2- Property Value = gmail
3- Depth = 10
 
4- FindChild : - A TestedObj may have one or more child objects with specified values of the specified properties so in this case we will using FindChild Method. FindChild method searches  child objects from the TestedObj.
Syntax -

           Set myObject = TestObject.FindChild(PropertyName, PropertyValue, Depth)    

Note - The difference between Find and FindChild is that, FindChild searches child objects, while Find searches TestedObj only.

5- FindAll : - FindAll method is used to search desire object from the TestedObj hierarchy. FindAll Method searches the entire object that have Specified value of the Specified properties. it's return a collection of objects and stored entire object list into an Array.
Syntax -
     
       Set myObject = TestObject.FindChild(PropertyName, PropertyValue, Depth)   

6- FindAllChildren : – FindAllChildren method is same as FindAll method (as mention above), it will search all the children and store them into an Array.

Set myObject = TestObject.FindAllChildren(PropertyName, PropertyValue, Depth)   

Note -
We can search a object with the combination of multiple properties and values. Suppose we want to search gmail link which is enabled on page, so in this case we will need to define arrays for Property Name and Property Value and use them like below-

Example
    
  PropertiesName = Array ("ContentText","ObjectType", "Enabled")
  PropertieValue = Array("gmail","Link", "True")

 Set myObject = TestObject.FindChild(PropertiesName, PropertieValue, 100)     


7- ChildCount : - An application, TestedObj may have one or more child like Processes is a child of Sys , Windows/Page is a child of process and so on. ChildCount property returns the number of children of the TestedObj.
Syntax -
       getChildCount  = TestObject.ChildCount                                                              

8 - RowCount : - As we know, TestComplete supports table/grid structure, suppose we want to know the number of records available in table/grid at that time we will use RowCount method/property. RowCount method/property returns the number of rows in table/grid.
Syntax -

       getRows  = TestObject.RowCount                                                                  

9- wItemCout: - wItemCount property is used to get the total number of items are available in the specified control of the TestedObj. Suppose you want the number of items from the drop down or combo box at that time we can use wItemCount property
Syntax  -

       getItemCount  = TestObject.wItemCount                                                             


10- wItemList : - it returns all item captions as a concatenated string of the TestedObj like ComboBox, ListBox, etc.
Syntax -

        getItemCount  = TestObject.wItemCount                                                           

11 - wText : -  wText property is used to get Text of selected Item from the list box or combo box
Syntax - 
        getText  = TestObject.wText                                                                              
12- wLinkCount : - A TestedObj may have multiple links, suppose we want to get number of links are available on TestedObj at that time we can use the wLinkCount property. it returns the total number of links in a Control.
Syntax - 
        getLinkCount  = TestObject.wLinkCount                                                           

13- wLinkText : - wLinkText property is used to get the text of link of the specified index.
Syntax -

        getLinkTxt  = TestObject.wLinkText(Index)                                                          

14 - ClickItem : - ClickItem is used to simulate mouse click over the TestedObj. ClickItem moves the mouse pointer on the item which is specified by index.
Syntax - 
        TestObject.ClickItem(Index)                                                                              
Note - If the item is not found, ClickItem fails and posts an error message to the test log.

15-Close and Terminate : - Close method closes the given tested application by sending a WM_CLOSE message to its main window and returns True if the application actually closes within the time period specified by the Auto-wait timeout project option. Otherwise, Close returns False.
 Syntax - 
        TestObject.Close                                                                                              
Terminate - Terminate tries to terminate all instances of the given application that were launched by TestComplete. Use this method as a last resort, when the TestedApp.Close method cannot stop the application. Terminate tries to close the application and returns True if the application actually closes within the time period specified by the Auto-wait timeout project option, otherwise it returns False.

        TestObject.Terminate                                                                                        


Note - When a process is closed by the TerminateProcess function, destruction and other finalization code of the application are not called. So, you should use the Terminate method when Close cannot stop the application.

Tuesday 11 February 2014

Basic Required methods in TestComplete. Part - 1

Deal All,

In this blog I am going to explain basic required methods in TestComplete along with syntax of that methods in VBScript.

1- Subroutine : - Subroutine is a series of statement enclosed by Sub and End Sub Statement, Subroutine performed action but does not return any value.
Syntax -

              Sub yourRoutineName
                  Statement 1 
                  Statement 2

                   Statement n 
               End Sub

2- Function : - Function is a series of statement enclosed by Function and End Function Statement, Function performed action and it can return the value. it take arguments that are passed to it by a calling procedure.
Syntax - 

        Function yourFunctionName()                Function FunctionName(arr1, arg2..argN)
            Statement 1                                                   Statement 1
            Statement 2                                                   Statement 2

             Statement n                                                    Statement n
        End Function                                              End Function                             

3- Variable : - Variable is a place holder it is used for storing information. In VBScript we can declare variable by using Dim Statement.
Syntax -

         Dim VariableName

4- CreateObject : - This function is used to create Object of any application/class
Syntax - 

        Set objName = CreateObject ("application.Class")
        Set objNotepad = CreateObject("Scripting.FileSystemObject")
        Set objExcel = CreateObject("Excel.Application")   

5- Message Box : - Display message/ information in a dialog box, message box wait till used does not click on OK button.
Syntax - 
        msgBox("Your Message/Information")

6 - Input Box : - InputBox is used to get the values from the user. After entering the values, if the user clicks the OK button or presses ENTER then InputBox function will return the text in the text box. If the user clicks on the Cancel button, the function will return an empty string ("").
Syntax - 

       inputText  = InputBox("YourMessage/Information")

7- SetText : - SetText method is used to entered text in a specific location like- Edit box, Password box, TextArea, or any text editor.
Syntax -

TestObj.SetText("YourText/values")                                                                       

8 - Keys :- The Keys action sends keyboard input to the object, it is used to simulate keyboard stroke on the object, we can simulate 1- Alphabet, 2- Number, 3- Hot keys, 4- Function keys etc,
Syntax - 

       TestObj.Keys("[Up]")
       TestObj.Keys("Your Text") etc....

9 -Click : - This method is used to click mouse button on the object
Syntax - 

       TestObj.Click()  or TestObj.Click

10 - Delay() :-Delays the script execution for the specified time period, Delays the script execution for xxxx. milliseconds
Syntax -  

      Delay(TimeInterval) like Delay(500)