Check if something exists next to an element


#1

Hi there,

in a list of numbers (the list is shown in an online application in IE) I would like my robot to find a certain number and then check if something is written next to that number. There is a possibility to export the list into pdf but I would rather want to avoid that step. Does anybody have an idea which activities I could use for that and how? I thought about using “Find Text Position” followed by an “Image Exists” Activity but so far I haven’t got it right.

Thanks in advance!


#2

Hi @Postman5002,

Use find children activity to get the all the elements and using get text activity or get attributes get the list value and store in list and you can check the number is exists or not.

Please refer this
https://www.uipath.com/kb-articles/return-all-elements-of-a-table-using-find-all-children-activity?hs_amp=true

Regards,
Arivu


#3

Along with @arivu96’s idea to use Find Children, you could also extract all the text using GetText or Extract Structured Data.

If you use GetText, then use a Regex pattern or string manipulation to pull the value next to that number.
If you use Extract Structured Data to a data table, then use .Select to find the row and pull the column of that row.

Regards.


#4

Unfortunately, the list itself is not built as a table. Only when I save the list as pdf, the numbers are shown in selectable rows.

However, what I am trying to find out is, whether an annotation next to that number exists or not (it doesn’t matter what the annotation says). The problem is that the annotation is contained in a sort of text box. So I guess I cannot check the annotation via the row number. I think the only way could be image recognition but I am not really sure how to do this.


#5

I’ve found a topic here on the board that seems to deal with a similar problem. However, back then, no useful answer was given. So is UI Path generally able to search e.g. for a number, which can be located in different places on a page and then extract the text that stands right next to it? I still haven’t found a solution.

Here is the link to the other topic:


#6

Hi @Postman5002,
Can you try find Children activity to get the list of elements.

Regards,
Arivu


#7

I’m not really sure how to set the properties within in the find Children activity to solve my problem. Could you describe it in more detail?

Thanks


#8

May not help much

What if you try “Find Relative Element” with cursort position Top Right, assuming the Text is on the Right of the number( different element).

relativeElement.Get("aaname").ToString

or


#9

Thanks for your help! But I am still a bit confused about how to use the find children activity. To be concrete, which Selector or Element do I have to put into the properties of Find Children?

To get a better understanding of the problem, I have built a dummy list (see Screenshot). There is the list of numbers which is not built as a table. Now I need to check if there is an annotation text right next to a number. If there is a box (which is the case in my example for the number ending with …7978) the output should tell me that there is one, it is not necessary to get the exact annotation text. I just need to differentiate between numbers in the list that have an annotation and the numbers that don’t have one.

Relative%20Position%20Element


#10

Hi there @Postman5002,
As an additional note, depending on the structure of the Visual Tree, you may be able to utilise the NAV tag.

This allows you to specify the element X number of positions before/after a given element.

For example, in the below Visual Tree:
image

I could identify the selector for ‘File’, which is:
<wnd app='notepad.exe' cls='Notepad' title='Untitled - Notepad' />
<ctrl automationid='MenuBar' idx='1' name='Application' role='menu bar' />
<ctrl name='File' role='menu item' />

However, I can access the ‘Edit’ element by changing the selector to the following:
<wnd app='notepad.exe' cls='Notepad' title='Untitled - Notepad' />
<ctrl automationid='MenuBar' idx='1' name='Application' role='menu bar' />
<ctrl name='File' role='menu item' />
<nav next='1' />

The result will identify ‘Edit’:
image

Thanks,
Josh


#11

Uipath does not find a single selector for the numbers in the list, since there is further information on the same sheet, so the correct example of my list would rather be something like this:

UiPath%20Screenshot1

When I use “indicate on screen”, uipath only selects the whole rows (without the annotation box, so it has Number and ID in one selector for each row). That makes it a bit difficult. However, the annotation box has an “unique” selector.


#12

This has nothing to do with Find Children.

Other Options :

  1. Use AnchorBase (Find Element on left Selecting your number and GetAttribute on Right with “innertext” or “value” attribute"(Continue On Error True)

  2. Adding to my prev post , try “Find Relative Element” activity with cursor position Top Right

image

One of below should give the annotation.

relativeElement.Get("value").ToString

relativeElement.Get("innertext").ToString

relativeElement.Get("innerhtml").ToString


#13

I don’t know, Find Children can be hard to understand sometimes but useful to know how to do also.

Personally, I have found using Find Element and/or Get Attribute really useful for finding items that are listed in a table.

For example, here is some pseudocode of something I have used recently.

For Each row In datatable
    Get Atrribute, with selector using  "aaname='"+row(0).ToString ....
         tableRow and/or tableCol attribute => store in variable
    Click, TypeInto, Check box using a selector with the tableRow and/or tableCol stored

Was pretty simple when I did it this way, but it also depends on the website and what is needed for the project.

Regards.


#14

Ok, I think AnchorBase or Find Element/Find Relative Element are the activities that will most probably get me to the solution I need. But here is what I do not understand:

  1. AnchorBase: I need to use the number I am looking for as the anchor, that’s clear. But how can I select the number (which can be anywhere in the list and which I even cannot grab as a single element via indicate on screen). Since uipath does not recognize the number as a single element, I guess Find Element cannot be used, correct? Furthermore, I understood that “Find Element” needs an element with a fixed location. That would not be the case with the number I need to use as the anchor.

  2. Same with Find Relative Element. I need a fixed element as a starting point. But the number can be anywhere in the list.

So how do I get the location of the number to tell the robot to go to the right and look for the annotation. I will not get the numbers and the annotations in one data table, since the annotations are just placed “on top” in a text box. So maybe I need to work with Screen Scraping?

Sorry for asking so much, but I am pretty new to uipath and I need to get this automation right for my company.

Thanks!


#15

You could actually do the reverse engineering and find all the TextBoxes using Find Children with ""<webctrl tag='INPUT'/>" filter.

For each children, you can get the Annotation (value) and Find the Relative Element (Left side) and get the Number (aaname)


#16

Hi JDavey,
Like ‘next’ and ‘up’ what are all the other attributes supported by the NAV tag? Are there any references to know more about that?