Using XPath to find rows where a specific column has value - xpath

I'm having trouble using XPath to find a row in a table where a specific column contains a value. The table has 10 columns where 2 of them will show Yes|No but I'm only interested in finding the value in one of the columns (the 4th one). My initial attempt was this:
//table[#id='myTable']/tbody/tr/td[text() = 'Yes']
but it finds it rows from both columns. I thought I could try something like this but it's not a valid expression:
//table[#id='myTable']/tbody/tr/td[4]/text()='Yes'
Any suggestions? Thanks.

You can try this way :
//table[#id='myTable']/tbody/tr[td[4][. = 'Yes']]
The XPath return row (tr) having the forth td child value equals "Yes".

Related

INDEX(FILTER(SORT not solving - Need an alternative?

Purpose: I'm trying to fetch the value from column c in the first sheet, where column a matches to column a in current sheet. If there are more than one matches in column a, fetch the most recent entry, according to the date in column b. If the most recent cell in column c was left blank, go back and fetch from the most recent matching row in which column c contains a value.
See the sample sheet, it's pretty clear.
I tried: =INDEX(FILTER(SORT('VISIT LOG'!C2:C,'VISIT LOG'!B2:B,FALSE),'VISIT LOG'!A2:A=A2,'VISIT LOG'!C2:C<>""),1,1)
But it's not working.
Any help will be appreciated!
you can try:
=INDEX(IF(LEN(A2:A),IFNA(VLOOKUP(A2:A,SORT(LAMBDA(z,FILTER(z,INDEX(z,,3)<>""))('Visit log'!A2:C),2,0),3,)),))
You can try with QUERY and MAP:
=MAP(A2:A,C2:C,LAMBDA(ax,cx,IF(ax="","",QUERY('Visit log'!A2:C,"Select C where C is not null AND A = '"&ax&"' order by B desc limit 1"))))

Remove all columns to the right of a specific column

I have an Excel template file with a dynamic number of columns that represent work week dates. Some users have decided to add their own subtotal columns to the right of those columns. I need a way to identify the first blank column, and then truncate that column and all columns following it.
I had previously been using the following script to remove all columns that begin with the word "Column":
// Create a list of columns that start with "Column" and remove them.
Removed_ColumnNum_Columns = Table.RemoveColumns(PreviousStepName, List.Select(Table.ColumnNames(PreviousStepName), each Text.StartsWith(_, "Column") )),
Based on being able to find the first ColumnXX column, I want to remove it and all columns after it
You can use List.PositionOf to get your ColumnIndex instead of parsing text.
I'd put it together like this:
// [...]
ColumnList = Table.ColumnNames(#"Promoted Headers"),
ColumnXX = List.Select(ColumnList, each Text.StartsWith(_, "Column")){0},
ColumnIndex = List.PositionOf(ColumnList, ColumnXX),
ColumnsToKeep = List.FirstN(ColumnList, ColumnIndex),
FinalTable = Table.SelectColumns(#"Promoted Headers", ColumnsToKeep)
Remove Columns after ColumnXX
Find the first column that begins with the name "Column" and delete that column and all columns following it. This parses the XX as the column index so you need to make sure you haven't deleted columns prior to this step. i.e. "Column35" needs to be the 35th column at this step in the code.
// Find the first ColumnXX column and remove it and all columns to the right.
ColumnXX = List.Select(Table.ColumnNames(#"Promoted Headers"), each Text.StartsWith(_, "Column")){0},
ColumnIndex = Number.FromText(Text.Middle(ColumnXX, 6,4)),
ColumnListToRemove = List.Range(Table.ColumnNames(#"Promoted Headers"),ColumnIndex-1),
RemovedTrailingColumns = Table.RemoveColumns(#"Promoted Headers", ColumnListToRemove),
To make this more robust I would prefer to have a way to identify the column index of columnXX without parsing the digits from it.

How to split a Webix datatable column into multiple columns?

In my webix datatable, I am showing multiple values in the cells for some columns.
To identify which values belong to which header, I have separated the column headers by a '|' (pipe) and similarly the values under them as well.
Now, in place of delimiting the columns by '|' , I need to split the columns into some editable columns with the same name.
Please refer to this snippet : https://webix.com/snippet/8ce1148e
In this above snippet, for example the Scores column will be split into two more editable columns as Rank and Vote. Similarly for Place column into Type and Name.
How the values of the first array elements is shown under each of them will remain as is.
How can this be done ?
Thanks
While creating the column configuration for webix, you can provide array to the header field for the first column along with the colspan like below:
var columns = [];
columns[0] =
{"id":"From", "header":[{"text":"Date","colspan":2},{"text":"From"}]};
columns[1] =
{"id":"To","header":[null, {"text":"To"}]};
column[0] will create Date and From and column[1] will be creating the To.

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).

Using XPATH to select the row *after* a row containing certain text

I can't work out if this is possible or not, I've got a basic table but that table has a varying number of rows and data within it.
Assuming the table is just one column wide and a random number of rows long to select a row containing the text "COW" I can do something very simple like do: -
table/tbody/tr[contains(td[1],"COW")]/td[1]
But lets say that this table contains two types of data in it, a list of animals and, underneath each animal, a list of attributes, all in the same column, looking something like this: -
COW
Horns = 2
Hooves = 4
Tail = 1
CHICKEN
Horns = 0
Hooves = 0
Tail = 1
Is there a way using XPATH to first identify the row that contains the text COW and then select the row directly after this to return the text "Horns = 2"?
Cheers
It seems that you want something like this:
table/tbody/tr[contains(td[1],"COW")]/following-sibling::tr[1]/td[1]
This will select the first td in the row immediately following the row which contains the td which contains COW.

Resources