QTP or UFT and Vbscript: Technical Interview Questions (Latest UFT Interview Questions) Set 2
January 8, 2019
Latest QTP Technical Interview Questions and Answers (Latest UFT Technical Interview Questions)-Set 2
Welcome to this post!-“QTP or UFT and Vbscript: Technical Interview Questions (Latest UFT Interview Questions) Set 2”
If you are looking for latest HP UFT \ QTP Technical Interview Questions, then you are at right place. This post consists of some exhaustive questions which had been part of interviews. Usually these are assumed to be known after having some years of experience in using the UFT or QTP, Go ahead and enjoy reading…
Q1. How to get to the textbox located inside the table of first row and second column?
Ans. To solve this Technical Interview Question we can use- ChildItem method
– which is use to locate the test object with given object class-type (like WebCheckBox, WebEdit etc), location and index inside the web table
Steps:
- First thing is that we need to check the location and id of the web table that can be used in your description of the object,
- Now focus on the child item what can be used to identify the same like id, row number, column number ,index etc.,
- Finally use the childitem method which is use to locate the test object with given object class-type (like WebCheckBox, WebEddit etc), location and index inside the web table.
- Code is discussed below:
The childitem method we have to specify the values for the row number, column number, Object type and Index(optional).
Now let’s focus on the steps,
‘declare the variable Dim txtChild Set txtChild = Browser("Browser_Name").Page("Page_Name").WebTable("html tag:=TABLE").ChildItem(1,2,"WebEdit",0) txtChild.Click
Q2. How to get the specific item count or control count inside the web table?
Ans. To solve this Technical Interview Question we can use-ChildItemCount.
– The ChildItemCount method returns the count of test objects of a specific type in the specified cell.
Steps:
- First thing is that we need to check the location and id of the web table that can be used in your description of the object,
- Now focus on the child item what can be used to identify the same like id, row number, column number,
- Finally use the ChildItemCount method to exactly locate item and return the count of same object
- Code is discussed below:
Suppose we are interested in counting the number of checkboxes present inside a cell on row=2, column=2 of the table, then we can follow as below:
‘declare variable for storing the count Dim CheckboxCount CheckboxCount = Browser("Browser_Name").Page("Page_Name").WebTable("html tag:=TABLE").ChildItemCount(2,2,"WebCheckBox") Msgbox CheckboxCount
Q3. How to get the all child objects count or child controls count inside the parent control of the web table?
Ans. To solve this Technical Interview Question we can use- ChildObjects
ChildObjects method which returns the collection of Child test Objects Contained within the parent test Object inside the webtable.
Steps:
- First thing is that we need to check the location and id of the web table that can be used in your description of the object,
- Now focus on the parent item (if applicable): what can be used to identify the same like id,
- Then look for initialize a local variable
- Finally use the ChildItemCount method to exactly locate item and return the count of same object
- Code is discussed below:
We can use ChildObjects method which returns the collection of Child test Objects Contained within the parent test Object inside the webtable. But we can directly get to the childobjects by specifying the webtable as parent and then using the method on this.
Example:
Suppose we are interested in knowing all the objects contained inside the webtable. This can help us in knowing exactly at which point in the collection of such test objects we can find our intended object and work on it later, like click, set etc.
‘declare variable for storing the collection Dim AllChildObjects ‘Declare variable for loop Dim k Set AllChildObjects = Browser("Browser_Name").Page("Page_Name").WebTable("html tag:=TABLE").ChildObjects Msgbox AllChildObjects.Count For k = 1 to AllChildObjects.Count msgbox k & " -" & AllChildObjects(k).GetROProperty("name") ‘If you want to work on some object, then mention like If strcomp(AllChildObjects(k).GetROProperty("name"),”your_object_name”,1) = 0 then ‘now here you specify your action AllChildObjects(k).Click ‘after this exit the loop Exit For end if Next
Q4. How to find row count and column count for the given web table?
Ans. To solve this Technical Interview Question we can use- RowCount & CoumnCount
Steps For RowCount:
- First thing is that we need to check the location and id of the web table that can be used in your description of the object,
- Now focus on the parent item (if applicable): what can be used to identify the same like id,
- Then initialize a local variable
- Finally use the RowCount method to return the count of the or number of rows present in web table.
- Code is discussed below:
‘declare variable like rowcount Dim RowCount RowCount=Browser("Browser_Name").Page("Page_Name").WebTable("html tag:=TABLE").RowCount
Similarly, we can proceed with ColumnCount:
Steps For ColumnCount:
- First thing is that we need to check the location and id of the web table that can be used in your description of the object,
- Now focus on the parent item (if applicable): what can be used to identify the same like id,
- Then initialize a local variable
- Finally use the ColumnCount method to return the count of the or number of columns present in web table for that row. So it means we can only get column count for specific row and not in general. The reason behind is that how tables are structured cannot be analysed easily so that we can receive a common column count across rows. As for each row may have different number of columns.
- Code is discussed below:
‘declare variable like ColumnCount Dim ColumnCount ‘this will return column count for row 1 ColumnCount = Browser("Browser").Page("Page").WebTable("html tag:=TABLE").ColumnCount(1) ‘this will return column count for row 2 ColumnCount = Browser("Browser").Page("Page").WebTable("html tag:=TABLE").ColumnCount(1) ‘this will return column count for row 3 ColumnCount = Browser("Browser").Page("Page").WebTable("html tag:=TABLE").ColumnCount(1)
Note: we need to pass row number in which we are interested to know the column count
Q5. How to get text or data present inside the specified cell of the web table?
Ans. To solve this Technical Interview Question we can use-GetCellData
– this method returns the text\data contained in the specified cell of the webtable. The only prerequisite in using this method is that you should be knowing the row and column number beforehand.
Steps For GetCellData:
- First thing is that we need to check the location and id of the web table that can be used in your description of the object,
- Now focus on the cell location, use F12 option in IE to locate exactly where is your data present,
- Then initialize a local variable
- Finally use the GetCellData method by specifying the row and column number.
- Code is discussed below:
Suppose we are interested in the row =1, column = 3 where our data is present, then
‘declare your variable to store the value or text or data Dim myData myData = Browser("Browser_Name").Page("Page_Name").WebTable("html tag:=TABLE").GetCellData(1,3)
Q6. How to get the row number for specified text inside the web table?
Ans. This is most common Technical Interview Question and is being asked frequently. The trick out here is the use of available function called GetRowWithCellText. This method returns the exact row of the cell containing the text.
Point to Note:
It returns the number of the first row found that contains a cell with the specified text, i.e. if you have same text in more rows it will only return first row.
Example:
Suppose we have text like “ Your Order ID is : 123377”
‘Declare the variable for storing the row value Dim rowNo rowNo = Browser("Browser_Name").Page("Page_Name").WebTable("html tag:=TABLE").GetRowWithCellText("Your Order ID is ")
If you would like to keep track of further articles on UFT (QTP). I recommend you to subscribe by Email and have new UFT articles sent directly to your inbox.
Excellent explanation. This article really solved lots of my questions. Thanks and Regards
Thanks for your comments, really appreciate!.
Enjoy reading.