Clicking on specific row in a WebTable using UFT/QTP - vbscript

I am having hard time clicking specific row in a Web Table. My code finding proper row, but when I use Child Item method it complains that Object is not found. Here is my code:
Desc = "Record to click"
If Browser("B").Page("P").WebTable("W").exist(10) Then
totalRows = Browser("B").Page("P").WebTable("W").RowCount()
For RowNum = 1 To totalRows
If aDesc = Browser("B").Page("P").WebTable("W").GetCellData(RowNum,2) Then
Browser("B").Page("P").WebTable("W").ChildItem(RowNum,2,"WebElement",0).click
End If
Next
End If
I spied on the value in the row it is Web Element, I tried to use Link- didn't work. Also I tried to Child Item(aDesc,2,"WebElement",0)- didn't work either. I used 0 for the index because there is only one element in the row - simple text. I keep getting this error in many other tests. On rare occasion this approach works in some tests, but most of the time it complains for absence of object.
Thank you very much for your help!

It happened with me as well. When I researched, I found in some of the old HP blogs that ChildItem method does not works correctly with WEBElement, but that was for QTP 9.0, and I was using 12.02.Anyhow, I can't figure out why its happening, and ended up using the following -
Set oExcptnDetail = Description.Create
oExcptnDetail("micclass").value = "WebElement"
oExcptnDetail("html tag").value = "TD"
Set chobj=Browser("").Page("").WebTable("Code").ChildObjects(oExcptnDetail)
chobj(0).Click
On a side note, in order to check a webelement/link exist in a certain row and column, use the following.
Browser("B").Page("P").WebTable("W").ChildItemCount(2,2,"WebElement")
Getcell data will return you anything that is in the desired row and column irrespective of what it is (link,webelement etc) and hence your assumption of if loop will go wrong.

Try this:
Browser("B").Page("P").WebTable("W").object.rows(rownum-1).cells(colnum-1).Click

I was trying to click the first link in my table and this code clicked the item
Set oDesc = Description.Create()
oDesc("html tag").Value = "A"
Set rc = Browser("B").Page("A").WebTable("html id:=gridTable").ChildObjects(oDesc)
rc(0).Click
'num = rc.Count() 'get the number of link in a page
'For i=0 to num-1
'ref = rc(0).GetROProperty("href") 'get the “href”propety of the i th link
'MsgBox ref
'Next
or
Browser("B").Page("A").WebTable("html id:=gridTable").ChildItem(2,8,"Link",0).click
successfully clicks the link I needed

Related

QTP UFT How to find a row number and column number? Angular JS

When I spy the table it shows just browser - Page - WebElement and also UI is developed in Angular JS.
I there any way to find row number and column number? By the way I am using UFT/QTP
From the source-code's image which you have attached, it is quite evident that the webElement corresponding to the rows have class = "ui-grid-row ng-scope". So, you can make use of descriptive programming. I assume that you already have added the object Browser(...).Page(...) to your OR.
Set rowDesc = Description.Create
rowDesc("Class Name").value = "WebElement"
rowDesc("Class").value = "ui-grid-row ng-scope"
Set objRows = Browser(...).Page(...).ChildObjects(rowDesc)
rowCount = objRows.Count 'This variable should now contain the total number of rows"
Now, this is just an idea which you can give a try. If it works for you, you can further enhance it to get the column count. If there is no way you can get the column count, then you can get the total cell count using the same method. In that case, you just need to change the value of property "class" to the one mentioned in the Object Spy Image("ui-grid-cell-contents ng-binding ng-scope"). Now you have Row Count and Cell Count. To get the column count, you can divide cell count by row count.(Again, this will give you correct answer ONLY IF there are same number of columns for each of tbe rows).

VB6 - Create subMenuItems programmatically

I'm working in a VB6 project and there is an existing menu, created with the menu creator. I am having trouble to insert subMenu programmatically in a MenuItem.
The first menu is File. It contains two menu items : Choice and Exit.
I would like to insert each row of a query (only the first column) at run time in Choice.
My recordset works well, but i need some help in the code below :
Do While rs_choice.EOF = False
'add column1 in Choice
'~Something~ = rs_choice.Fields("column1").Value
rs_choice.MoveNext
Loop
PS : No one MenuItems have defined index.
Can someone help me ?
Using the designer give Choice a single sub-item called mnuDynamic, give it an index of 0.
Loop the recordset loading new items:
Dim i as long
Do While rs_choice.EOF = False
If (i > 0) Then Load mnuDynamic(i)
mnuDynamic(i).Caption = rs_choice.Fields("column1").Value
rs_choice.MoveNext
i = (i + 1)
Loop

Excel for Mac VBA - Go to specific row of table and work up the rows to first row

I´d like to find a specific row of a table in Excel for Mac 2011. From this row, I want to work up the table to the 1st row. I´m sure there is a simple way of doing it.
Also, what is the tweak, to work down to the end of the table from a specified row?
Thanks in Advance!!
You might want to provide an idea of what you have tried...as well as how you want to find the starting row. Regardless, here I have finding the end row of your data (based on column A, change as needed). This goes to the bottom of the sheet, then essentially does Ctrl + up arrow to get the last row that has something in it. Then starts from there and steps backwards through the rows until row 1. Nb you don't have to set i to endRow, I just did in case you wanted to use endRow for something else.
Public Sub testing()
Dim ws As Worksheet
Dim endRow As Integer
Dim i As Integer
Set ws = ThisWorkbook.Worksheets("Sheet1")
endRow = ws.Range("A" & Rows.Count).End(xlUp).row
i = endRow
While i >= 1
'Working up the sheet doing whatever
i = i - 1
Wend
End Sub

Filter in OpenOffice Calc

Scenario:
I have a spreadsheet with info from a giveaway campaign in which I get paid per new Twitter follow my client receives through my campaign. Unfortunately the application I use does not track new followers vs existing ones because they offer an entry for new and existing followers for the "Follow on Twitter for 1 Entry". Because I also offer other means to gain entries I need to export the data and filter the results to show only those who've gained an entry on the Twitter Follow and then filter out those who are new vs existing by means of a separate application.
Problem:
There should be a separate column for each data type; name,email,action, etc. The action column is where I would expect to find the "Follow On Twitter" but the file is very disorganized and the action can be found in many different columns. Therefore I need a way to show only the rows in which there is a field with "Follow on Twitter". I am at a loss to try and figure out how to do this.
The following macro will search for "Follow On Twitter" in each cell. For each row, if a match is found, the row will be shown, else it will be hidden. You will have to adjust the macro to match your sheet's total number of rows/columns.
Sub Dummy()
GlobalScope.BasicLibraries.LoadLibrary("Tools")
Dim ActiveSheet As Object
ActiveSheet = ThisComponent.CurrentController.ActiveSheet
Dim r,c As Integer
For r = 0 To 25
Dim found As Boolean
found = False
For c = 0 to 10
Dim cell As Object
cell = ActiveSheet.getCellByPosition(c, r)
If cell.String = "Follow On Twitter" Then
found = True
Exit For
End If
Next c
Dim row As Object
row = ActiveSheet.getRows.getByIndex(r)
row.IsVisible = found
Next r
MsgBox "Done"
End Sub

Vb Changing column index not displayed column index for gridview

Hi every one i have a problem which i need to change the index of my gridview. Not only displayed index. Cause i need it to populate into another document.
Dim haa As Int16 = DataGridView1.ColumnCount
DataGridView1.Columns(1).Index = haa - 1
I have tried this and it says Property Index is readonly.
Any idea how to make it dynamic so that ill be able to alter it ??
I have tried doing this too it works for displaying but when populating it does not work.
DataGridView1.Columns(1).DisplayIndex = haa - 1
Aside from this i tried this too
DataGridView1.Columns.Move(DataGridView1.Columns["Total Of Field1"], haa -1);
However it does not work.
Hi Every one i found a way to really shift shit out of a column. This is the way.
Dim abc As DataGridViewColumn = New DataGridViewColumn
abc = DataGridView1.Columns(1)
DataGridView1.ReadOnly = False
DataGridView1.Columns.RemoveAt(1)
DataGridView1.Columns.Add(abc)
So i just take out the column i want to put at the last and append it back.
But i guess its a really bad way anyone has better idea ?

Resources