Get table row number value from datatable

Original Portal Screenshot:

Selector for Download buton

<webctrl aaname=‘Download’ tableRow=‘121’ tag=‘IMG’ />

Above the output of table extraction value from the page and stored in Data table

We need to get the row rumber if the text contains (.png) in “F” or “Column-4 Src” column to pass that row value to table row of download selector. (<webctrl aaname=‘Download’ tableRow=‘121’ tag=‘IMG’ /> )

How to get the row number if the text contains (.png) in “F” or “Column-4 Src” column?

So that I can assign that variable value for “TableRow “ of download selector and click inside for each row activity?

if your case is to check for all then use for each loop

in for each use if condition to check column contains the specified value ex .png or src

in then block use assign activity to get the index of row , you will get index automatically as it is property of for each

then use the index to use in selector of download

Hope this helps

Regards

@Sathish_Kumar_S

inside the for each row datatable

Use if condition

row("F").ToString.Contains(".png") Or row("Column-4 Src").ToString.Contains(".png")

In then part assign a variable like

rowNumber  = row.Index.ToString

So then use that “rowNumber” in the selectors as variable it will be dynamic.

it was not my ask

Regards

1 Like

Expected index number for the condition is 3 , 5 & etc…

But getting the output as 1,3,4,6…etc

How to fix it?

image

Where you wrote this

dt_DocumentResults.Rows.Index(CurrentRow)

Hi @Sathish_Kumar_S ,

When we go ahead with the Datatable, the index starts from 0, hence you get the index numbers in that manner based on the datatable rows and not the Excel row numbers. To get the Excel row numbers, you would need to add +2 to the index retrieved.

But again it also seems that you wouldn’t require the Excel row numbers, as you are trying to target the Download button in the Selector.

Just check the row number in the First Download button (which contains .png) if it is equal to the index retrieved for that using the Datatable. If it is equal it would mean that the row indices in the Application Table also starts from 0, else we need to add the offset accordingly to it to fetch the correct row index.

Inside then block in if condition (CurrentRow.Item(“Column-4 Src”).ToString.Contains(“.png”))

@Sathish_Kumar_S

Is it necessary for you to extract the data or are you extracting only for finding the row number?

This looks like a classic case for for each ui element activity

That will solve these issues for you and you have filters which you can include to check for png and etc

For each ui element you can use on the row directly instead of cells you need…that way all data can come in one aingle innertext also and then index if needed can come from the for loop index only directly…

Even the same can be obtained by using for each row activity in the properties for for loop…no need to do indexof function again

Hope this helps

Cheers

@Sathish_Kumar_S

Use for each ui element activity and indicate downlooad button if you want to click on every download

Else if needed only selective download yhen indicate whole row as one element and then get the innertext…and check for required values if present then you can do get children on row to get the downlod button and click it…else can use the index from for loop peoperties and use it…(currentindex) in your selector if the innertext contains the required values

Cheers

Extracting for following reasons :-

  1. To get download button row number
  2. if Key column has 2 files ( Ex : Please check PV 1209 Key) German & English then download only "English " version file
  3. IF Key column has only one file then we can download any version of file

@Sathish_Kumar_S

First check if there is difference between the selectors of download buttons for german and english…if there is then we can choose one in for eqch ui element activity

Or

As you are already using we can use the same way…but to get row index you can directly use the property in for each row activity instead of indexof function again

Cheers

ok. How do i use index value output of for each row activity to find the row number using below condition?

Check here

image

Main.xaml (12.7 KB)

@Sathish_Kumar_S

Inside your of condition just use the output of index…say varindex…that will already be the required index number…no assign is required

Cheers

ExportData1.xlsx (10.2 KB)

I have applied the same logic … but it is still giving wrong index number
Attached the table extraction output file for your reference. Can you replicate with the file attached?

Check It here

Main.xaml (12.7 KB)

image

image

1 Like