UI automation: empty fields and dropdown menu


I have a workflow that is interacting with a desktop application to insert personal data, however, I am facing 2 problems:

  1. Is there a possibility to empty application fields when clicking them and before inserting data? I can’t use a double click action on the field since it would only work properly when the field contains only one single string/element. Also, the application doesn’t accept keyboard shortcuts (like ctrl + a to mark all text of an element).

  2. Can I dynamically change what the bot is supposed to choose from a dropdown menu? I want to select a specific postal code for each person.
    I read some posts about this, but these where in the context of web pages where Xpaths could be extracted and used as a selector. I also can’t use the enter keystroke action, because for example in the case of “LA” it would jump back to “AL” since the letter L was the last one that got sent (typing the letters L and A in succession will therefore not select “LA”). Currently I use if-statements that are covering all cases.

Hi @alexr what do you mean the application doesn’t accept keyboard shortcuts? It doesn’t accept them only in case of a bot? Or cannot you use them when you will in the field manually, as well?

Strg + a doesn’t work in general, no matter if done by the bot or by me. But for example, strg + c or strg + v works.

Try using triple click to select all text.

As for the second question, have you tried copying the UI selectors of the dropdown options using Inspector or by recording your actions? It the selector has a property that contains the text, you can dynamically change it using values in the variables.

For examples, you can click on option in this dropdown in Excel by using the same selector in a For Each Loop.

[CLASS:NetUITWBtnCheckMenuItem; NAME:${element}; TEXT:${element}]

I recreated the Excel example and it works with different, dynamic elements.
But when I do the same for the application, the switch window or. the windows’ name is “#32769” (“Net UI Tool Window” in Excel example) and the generated selector is “[CLASS:ListItem; NAME:#elementIclicked; TEXT:#elementIclicked]”.
When I run the script I get the following error:

“Caused by: org.openqa.selenium.NoSuchWindowException: Window ‘[CLASS:#32769]’ is not found”

Can you share the screenshot of the Window action that fails?

And here is the click action which is following:

Is the window opened on the screen at the time when the bot is trying to switch to it?

Yes, the bot opens the dropdown menu in the action before, then when the dropdown menu is visible the switch action starts, but I get the error mentioned above.

Try defining a bigger timeout in the Window action.
Also, try recording the clicks inside the dropdown window again. Does it always record the same window name, #32769?

Yes, it will always generate “#32769”.
But I have another action that is clicking on another tab and menu item of the application, which works perfectly fine and in that case the window is labeled “#32768”.

Hmm, try using the option “Enter window title or part of title” and using 32769.
Also, try adding a timeout to the action, like 10,000 or 15,000 ms.

That also didn’t work, but I did it like this now:
I use the drag mouse activity to select the entire text of a field and replace it. Then I also don’t have to interact with the window that made problems mentioned above.

1 Like