Add variable data to a column in a data table

I have a loop that collects data from several textboxes on a webpage. I would like to write the data collected from each textbox to the next column in the same row of the datatable. Each row will then be the data for a specific webpage.

For instance, page1 has 3 text boxes:


The new datatable should look like this for the header and first row:


I don’t know how to write TextBox79 in column Result1, then Textbox80 in column Result2, and so on.

Here is my process: First, I create a datatable with 4 columns: PageNo, Result1, Result2, Result3 using BUILD DATA TABLE. Then my process finds the first textbox on the page using GET TEXT. Since the textbox number changes on every webpage (and even on the same webpage on different days), I use the ANCHOR BASE. I then take the attribute from the textbox element “webctrl name” near the anchor using GET ATTRIBUTE (e.g. . Then I create several variables that increment by one based on the first textbox. On each pass it collects the data from the next textbox in the series into the RESULT variable.

Note: I can’t use DATA SCRAPING because the textboxes are actually dropdowns and I get all the data in the dropdown not what was actually selected.

I tried to do three separate GET TEXT activities but thought it would be easier and more scalable to do a loop. Otherwise, for every textbox, I would have 3 extra assign boxes that select the number portion of the webpage element, converts the attribute to a number and increments the number, then converts the number back to a string and concatenates it with the text part of the webpage element (e.g. TextBox79 > 79 > 80 > Textbox80).

GET TEXT: using variable Textbox as the webctrl name

Main.xaml (9.8 KB)

declare dataRowTemp (dataRow) and resultIndex

every time you add new row

  1. assign dataRowTemp = dt.newRow
  2. assign dataRowTemp("PageNo") = #your page Number
  3. assign resultIndex = 0

in your for loop
assign dataRowTemp("Result"+resultIndex.ToString) = text
assign resultIndex = resultIndex + 1

after for loop, use add data row activity

test.xaml (9.8 KB)
I think this would help you to resolve it.

Thank you. I was able to get it working using your solution!

1 Like

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