UI Click on each table rows after scraping a website with "Extract Table data"

Hello.

How can I click on every row on a HTML table (rows, I want to click on the text on each row to “activate” the current row)? I can do this either while going through the table or doing them all in a bulk-manner after scraping the table data. Doesn’t matter.

I have tried to use “For each row in Data Table” and then using OCR click on text with CurrentRow.Field<string>("Column name"), but the OCR just keeps timing out.

Since UiPath does collect the table data to the datatable so nicely, I was thinking that there must be a sophisticated way to click on all the elements (for example column #2 for each row) so that I could activate each row while traversing the table. Could this forum help me here?

@jussi.hietanen

The standard “Click” activity did not yield the desired results?

How can I wrap a “for each” to the click so that the click happens on every row?

@jussi.hietanen

str_variable = currentrow(“column name”).tostring
In the click activity selector, pass the aaname or innertext property as str_variable

Thanks for the reply. Unfortunately I cannot find a click activity selector. Under click’s “Target” property however I can find Fuzzy Selector and Window Selector. If I change the “Native Text” to str_variable (CurrentRow.Field(“Name”)) as you pointed above, it will only give errors

“Error ERROR Validation Error Target is not valid because no targeting methods are enabled. Main.xaml”

I can find “Selector” field from under the Click activity’s “Target” property. Is this what we are looking for? Now it is null, but it would require some C# variable? However, I cannot find a “Selector” activity from the activities list.

@jussi.hietanen

Try giving this in the click activity selector:

"<html><body><table><tr><td>" + CurrentRow("Name").ToString() + "</td></tr></table>
</body></html>"

After indicating the html element the browser, you can pass this in the strict selector.

Thank you very much @supriya117 ! I got it working now.

Now there’s only one thing left:

The extracted table data seems to miss a whitespace from the table cell string. When looking at the table from browser, the cell in question has an ID and then a document name followed by the ID in following format “ ”, for example “78123 Test Document” However, the aaname and innertext have two whitespaces between the ID and document name, whereas the extracted data and what the user sees when browsing only has one whitespace. For example:

“78123_Test Document”
vs
“78123__Test Document”
(spaces replaced with _)

How can I either change my table extraction rule or click target activity rule so that they would always match 100%?

My table extraction rule is currently:
extract metadata:

"<extract><row exact='1'><webctrl tag='div' /><webctrl tag='table' idx='1' /><webctrl tag='tbody' idx='1' /><webctrl tag='tr' idx='1' /></row><column exact='1' name='Column0' attr='text'><webctrl tag='div' /><webctrl tag='table' idx='1' /><webctrl tag='tbody' idx='1' /><webctrl tag='tr' idx='1' /><webctrl tag='td' idx='2' /><webctrl tag='div' idx='1' /><webctrl tag='div' idx='1' /></column><column exact='1' name='Column1' attr='text'><webctrl tag='div' /><webctrl tag='table' idx='1' /><webctrl tag='tbody' idx='1' /><webctrl tag='tr' idx='1' /><webctrl tag='td' idx='3' /><webctrl tag='div' idx='1' /><webctrl tag='div' idx='1' /></column><column exact='1' name='Column2' attr='text'><webctrl tag='div' /><webctrl tag='table' idx='1' /><webctrl tag='tbody' idx='1' /><webctrl tag='tr' idx='1' /><webctrl tag='td' idx='4' /><webctrl tag='div' idx='1' /></column></extract>"

selector:

"<webctrl id='ext-gen112' tag='DIV' />"

my click selector:

"<webctrl text='" + curr_click_target + "' parentid='ext-gen112' tag='DIV' />"

Where “curr_click_target” is CurrentRow.Field<string>(“Name”)

Thanks in advance!

1 Like

If you want to change the table extraction, a starting point would be to explore the table in UiExplorer. I the text is displayed to the user in a different format, that’s likely to be available somewhere in the UI tree. Once you find the element, you can finetune the extraction. For that, here’s an excellent guide [HowTo] Data Scraping - Advanced Configuration - Text Field, Image Source, Url, CSS Classname, Hover text - News / Tutorials - UiPath Community Forum - https://forum.uipath.com/.

The element “text” actually seems to have 2 spaces in it. So it seems like the “Extract table data” actually removes one space from the attribute before storing it. Is this what happens really or am I just missing something?

With UI Explorer’s Property Explorer I can see that there is a property named “visibleinnertext” which has one space only! Choosing this as the click target worked! Thank you a lot everyone!

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