Clicking on particular element in DataTable with For Loop

I created a script using an extracted DataTable, a For Loop and an If Statement. Process flow below:

  1. Extract a table of 6 columns
  2. Iterate through every row and find the keyword ‘DHL’ or ‘FEDEX’ on column 2
  3. If the keyword ‘DHL’ or ‘FEDEX’ exists (for example, Row 3), use this row number 3 and
  4. Click on the word ‘View’ located in column 1

Step 1,2,3 is working perfectly. However, the script is now forgetting to click on Row 3, but keeps on going to click Row 1 (incorrect) instead.

Since View the target is the same throughout the table how can I click on the correct View in the correct row?

Hi,

Please make your selector dynamic in click activity by making use of row number as a variable in your selector.

Hope this works for you.

Thanks

@WilfredNg

Better use for each ui element activity directly…which provides you with filters as well

Else follow as @Hari_Prakash specified

cheers

Hi. I’ve made my selector dynamic. But how can i make use of the row number as a variable within my selector?

I’ve saved my row index variable as - CurrentRowIndex.

@Hari_Prakash

In place of tablerow='1' use tablerow='{{rownumbervar}}'

or open selector in the click activity and right click on number 1 and select the variable you need

cheers

I’m using the variable but it’s still repeatedly pressing the same first button

@WilfredNg

Can you indicate the first row and the second row and check if the tablerow is the only difference you see or is there anythign else

Also better remove the css selector for the table

Cheers

I’ve removed the entire CSS selector line but it’s still the same. Yes I believe the only difference is the tablerow

@WilfredNg

Can you print the currentrowindex and see if it is incrementing

cheers

Yes It’s incrementing

image

@WilfredNg

Are you usign strict selector only or fuzzy?

can you show the click properties please

cheers

I think I’m using both? There’s value in both selectors

Oh I realised I didn’t check the use “Strict Selector”. It’s sort of working now…

There are 5 different rows, 5 different links. But the first 2 is opening the same no.1 link while the rest are proper. Should i unselect the fuzzy selector?

image

@WilfredNg

Yes plase you can use only strict

Cheers

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.