Get Element (Chrome) using a data attribute like data-id="value1"

I would like to be able to Get an Element using a data attribute value as the selector. Anyone can orient me in the right direction?

Thanks

Hi @Evelio87

You can modify the xpath from the “Get Element” as follows:

"xpath": "//*[@data-id=\"value1\"]"

By using a wild-card character, “*”, in the XPath expression, I instructed to select all elements that have a “data-id” attribute and value, regardless of their position in the document hierarchy or the presence of other elements in the expression. This makes my selection more flexible and robust (I think :sweat_smile:).

I hope this information proves useful.

1 Like

Thank you so much knwts, I really appreciate your help.
I have been trying what you recommend and it’s not working, also I tried to use the cssselector instead of xpath and didn’t work.
I enabled the slow motion and added a move mouse activity after the Get Element activity to see what is happening and the mouse is moving to a wrong position.
Also when I click on the selector and click on Select button to automatically select any html element it doesn’t work, so there are not automatic selection.
Maybe is my chrome plugin, I tried to uninstall is and install it again and didn’t work.

I am not able to select any item from the browser.

Do you have any idea what is happening?

I am using OpenRPA.NM → Get Element

For example: I am trying to use this selector to reproduce the issue and I am not able to locate the element neither, I am using the OpenUrl activity. I am able to open the url in a new tab, but when I want to locate the input it is not working, also when I open the selector window and click on Select button to select the input automatically clicking over it doesn’t work. Do I have something wrong in my environment?

[
  {
    "Selector": "NM",
    "browser": "chrome",
    "frame": "-1",
    "url": "https://docs.openiap.io/openrpa.html"
  },
  {
    "xpath": "//*[@id=\"rtd-search-form\"]/input[1]"
  }
]

[13:42:05.047][Output] Supplier1 completed in 00:01.493
[13:42:04.884][Error] System.NullReferenceException: Object reference not set to an instance of an object.
at OpenRPA.NM.NMSelectorItem…ctor(NMElement element, Boolean isRoot, Boolean hasAnchor)
at OpenRPA.NM.NMSelector…ctor(NMElement element, NMSelector anchor, Boolean doEnum, NMElement anchorelement)
at OpenRPA.NM.Plugin.OnMessage(NativeMessagingMessage message)
[13:42:03.554][Information] Supplier1 started in 00:00.000

I found up that, when I am using OpenRPA locally “wsurl”: “ws://localhost.openiap.io”, the selector is not working but when I change to the demo one “wsurl”: “wss://app.openiap.io/” the selector works properly.

Any idea what I am missing in my environment?
I am using the normal installation, everything else works ok, including adding a new agent which install/deploy a new node-red container locally.
docker-compose.yml

That sounds very strange. Openrpa selectors are not affected by what openflow ( or none ) its connected to. If you can make an simple reproducable example i would love to see it, so I can fix it.

PS: If you need the recorder to support finding by the attribute you can add custom properties under recorder setting => nm

Hi Allan, thank you so much for your help and quick response.
I cannot find the solution to my problem yet, I uninstalled OpenRPA, deleted the settings folder and installed again and didn’t work. When I point to wss://app.openiap.io instead of ws://localhost.openiap.io works properly. I made a video about it. Can you provide me any support email in order I can send you small screen records I did?

Also, when pointing to the cloud demo url, when I execute a workflow (which open a URL) it opens a new tab each time because I settled down NewTab = “True” in the Open URL activity, and when I change the settings to “wsurl”: “ws://localhost.openiap.io/” and execute a similar workflow, only opens the Tab the first time and the subsequent execution it doesn’t.

Thanks and regards

Hey
You highly recommend you use the recorder to get started, that will help you in seeing one way of getting things done. But in this specific case that would not help, since you cannot record opening a tab, but there is a trick. If you click in a sequence in a workflow and then click on “nm” in the status bar, it will add a “openurl” with the browser you have open, and the url that is currently open right now ( if more are open, it will prio chrome first )
If you look in the activities added by the recorder ( or clicking nm in status bar ) you would see “browser” is a string containing the name of the browser and not the path to the browser. So in you video example “browser” should be simply “chrome”
That is also explained here under open url
https://docs.openiap.io/openrpa.html?highlight=email#id91

1 Like

I tried what you recommended me, however I am not able to use the recording functionality properly, it is not working for me, I did a quick video about it, also the virtual resources associated to OpenRPA are increased very quick and high. I don’t understand what is happening, I was able to use the OpenRPA selectors and record functionality without any issues few weeks ago.
In this link I have included the new video
https://drive.google.com/drive/folders/1rYP_dwxD41v_ctJ8dq_d7cyMqGgjTAEx?usp=sharing

I had to kill the service in order to close the OpenRPA because the stop button didn’t worked.

I am going to set up a virtual machine and install OpenRPA there to see if the selector works properly, if it works, means I have some issue on my Environment/OS, so I will have to format my computer.

Thanks you all!

Hey

  1. I’m not sure why the highligher is just “stuck” in the corder like that. Normally that happens if the recorder thinks it found a different application under the cursor, or if the page contains Iframe with under certain conditions. But the page you have open does not use iframes, could it be your screen recorder that is placing an overlay or the screen ? I often see that, with some screen recorder, or when using some meeting software like MS Teams native application.
    how do you connect to the machine, is this your physical machine or an RDP/VDI machine ?
    If this is a physical machine your working at, and it also happens while not using recording software, then I would say that is a bug. I would love to know, how to reproduce that on my machine, so i can get that fixed. ( note iframes and multiple monitors is not supported

  2. Regarding memory usage, I don’t see OpenRPA consuming much ram there. It’s well known, the workflow designer will consume an accumulated amount of ram ( it’s memory leaking ) so doing many hours of recording it’s a good idea to restart OpenRPA once in a while.
    Doing production you should always run in agent mode or at least make sure the designer is not open, since having designer open will add an signification over header to compile XAML and do debug tracking.
    A “base” OpenRPA with a few workflows and no exstra extensions installed, should not be use more than 400-500MB ram, but it’s not uncommon to see it use 2-3 Gigabyte ram doing recording/working with large (many pages of) workflows. But once deployed, thise should keep below then 500MB limit when run without the designer ( unless your loading many data, like big excel files etc )

Thanks Allan, for your quick response, about the Memory uses, It was because wsl where docker container are running, I have fixed it by limiting the resource that it uses.

About the Selector issues, I disconnected one of my two monitors and it works better, but there are some inconsistency when selecting the element in chrome, its highlighting an incorrect area and sometimes it’s not able to select the element. I am not able to open a new tab in each execution yet despite I have NewTab=True in the open url activity.

Also when I close the selector the highlight area is keeping permanently active in the screen, I have to close the OpenRPA in order to make it disappear.

Thanks

Close the browser and reopen it.
There is an issue with chrome not always sending window size when going from or to miximized.

I did it and the highlighting disappeared, now I am trying to move the mouse to the selected element and it’s not working, that was my original issue, because I wanted to get an Element and move the cursor over it to display a menu.

I have pending two issues to resolve:

  1. Open a new Tab on each execution.
  2. Move the cursor to the selected element using Get Element

Also I notice when I use the selector (which is working now because I disconnected the second monitor), the highlight area is showed in a different place and not where I have the cursor positioned. I have reproduced this behavior in a new video “Move Mouse not working.mp4” at OpenRPA_Allan (Screen Records) - Google Drive

Regards and thanks

OpenRPA is designed to primarily avoid physical mouse and keyboard ( unlike most other RPA software )
The whole points is to try and avoid using the physical mouse and keyboard to get the most stable automation. When that is said, there are always corner cases where using the physical mouse or keyboard is needed. If this is one of those cases, then let’s keep trying to solve it.

I get the feeling you are constantly moving or resizing the browse ( please correct me if I’m wrong, but the symptoms your seeing sounds like it ) most people will not notice since getting/setting data in the browser does not care where on the screen the browser is …
Could you please close all chrome instances, and run the workflow again, to make sure it’s consistently having issues locating the browser window ? ( so close chrome and do not open it, let OpenRPA open chrome when executing OpenURL ) …
If it works, close chrome again, and run it 2-3 times more to see if it keeps working or not ?
If it does not work any time, then try adding a delay activity with Duration set to 00:00:01 right after the move mouse to rule out if ending the workflow is interfering with the mouse
image

I did what you recommended, closed the browser and let OpenRPA open the browser, also added the delay activity and it’s happening the same behavior “The cursor is moving to the wrong position”.

Hmmm, i would like to see that if possible.
Would you be open for doing a meeting and sharing your desktop using anydesk?
If so, i can send you a link where you can book in my calendar.

Yes sure, thank you so much for your support! The whole OpenRPA framework and you are awesome! I’ll be sharing the details to set a meeting and review the described behavior. Regards

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