Get text from a web table

Hi Community,

I’m trying to get the text from a web table to validate it it contains specific text, but it is not getting the text from some rows (see attached screenshot), in this case is not pulling the text from row 2 and 4.

Any ideas how to get the text from all rows?

Thanks,
Ruben B

I used the activity “Extract Table Data” and for some reason it is also ignoring the value of the second row. Any idea why is this happening?

Hi @jpereyra

In the Extract DataTable activity properties, there are options to configure the extraction settings. Make sure the “MaxNumberOfResults” property is set to a higher value or leave it empty to extract all rows. You can also check the “Auto Extract Headers” option to include the table headers in the extracted data

@jpereyra,

If you just want to check any text is available on the page not in any specific row or column, I would suggest to use Get text activity to get full text of the page. It will return you a string which will be easy to check if desired string is available on the page.

Thanks,
Ashok :slightly_smiling_face:

Hi @jpereyra

You can also use CV ScreenScope Along with CV Get Text & For checking if the text contains the specific text you can use the The TextOutput.Contains("ValueYouWantToCheck") method to check if a specific substring (“ValueYouWantToCheck”) is present within a string variable (TextOutput).

Hope this helps :slight_smile:

Hi Pradeep931,

The limit extraction setting is set to “no limit” but it is still ignoring the value from the second row as you can see in the attached screenshots.

Screenshot 2024-08-19 at 1.07.41 p.m.
Screenshot 2024-08-19 at 1.08.18 p.m.

Hi AJ_Ask,

thanks for the information.

I tried the way you said but it doesn’t work when selecting an area because it contains input fields. It only allows to select one of them.

Any ideas?

Thanks,
Ruben B

Hi @jpereyra ,

Just throwing a different approach here, might be easier than trying to extract it as a datatable in this case.

If each “row” has its unique selector, Try to use Find children to list all of the possible selectors (or children/descendants) inside the said table, and then loop each one of them, extracting the text attribute, to build the DT yourself.

My approach would be (helicopter view)

1- Find children on the table selector (Expecting to get a list of selectors that include each one of the rows inside the table)

2- For each UiElement in var_ChildrenResult (Get Attribute - innertext (or the attribute that has the text value, you can check it on UiExplorer)

3- If text is extracted (to skip possible children that are not what we expect) - add datarow with that value in a parallel DT

If I am assuming right and each row has its unique selector, this would be a way to bypass the extract datatable, and still extract all the information. Give it a try and best of lucks!

BR,
Ignasi

Hi ignaisi.peiris,

Thanks for sharing your knowledge.

I was trying this option yesterday, using the find children activity, then use a for each activity to get their value and store it in a variable, then I put a log message to check the values. Then I added the If activity to validate if the text is present in the values, if yes, just click the save button. If not, add the value in the empty field and then save.

It works to get the children values
Screenshot 2024-08-20 at 6.01.51 p.m.

i added a log message in “then” and “else” to check the values here, but they are empty at this point, so the value is added no matter what.
Screenshot 2024-08-20 at 6.03.52 p.m.

Seems that the values are not being passed to the if activity.

Any suggestions?

Thanks,
Ruben B

Hi @jpereyra ,

Would you mind sharing a screenshot of the code, or upload the sequence for further analysis?

Keep in mind that depending on how the Find Children is configured and how the website is built, not all the children will be of your interest, and there might be “noise” in the middle that you don’t need.

BR,
Ignasi

Hi @ignasi.peiris ,

Sure, here you go.

Here I’m using the find children activity and the selector is configured find only the fields I need and children output is called “BadgeExists”

Then I have the for each activity, to go to each children and get their attribute “value” and save it in the variable called “BadgeValue”

These two activities are running as expected and getting the values from the fields I want

Screenshot 2024-08-20 at 6.01.51 p.m.

Then I have the If activity which logic is set to if BadgeValue contains Badge (which is a string variable that has the text I want to validate) then log a message with the BadgeValue to validate, click a save button and log another message. Else log a message with the BadgeValue to validate, type the value of Badge, click (select) the result, click on the save button and the log a message.

It is always executing the “Else” sequence because the values we get in the for each activity are not being passed to the if sequence.

Screenshot 2024-08-20 at 6.03.52 p.m.

Thanks,
Ruben B

Hi @jpereyra,

From my understanding, you’re looping through the children and assigning each attribute to the “BadgeValue” variable. However, you’re overwriting this variable with each iteration, which means that by the time you reach the “IF” statement, only the last child’s value remains.

For example, if you have 3 children:

  • MiniMBA in Marketing (650221)
  • Mini MBA in Management (715561)
  • No value

When you reach the “IF” statement, the first two values have already been overwritten, so you’re only checking the “No value.” That’s why the “Else” condition is always triggered.

If you need to validate each line individually, the “IF” statement should be placed inside the ForEach, immediately after the Get Attribute.

If your logic is something like “If any text contains my badge, click save” you’ll need to store all the texts and check if any of them contain your text. This would work with your current design, but you’ll need to store all the values in a collection, not just a single string variable. Alternatively, you can keep the “IF” inside the ForEach and use a boolean to track whether your word is identified.

Hope this helps :slight_smile:

BR,
Ignasi