robocorp / rpaframework

Collection of open-source libraries and tools for Robotic Process Automation (RPA), designed to be used with both Robot Framework and Python
https://www.rpaframework.org/
Apache License 2.0
1.17k stars 225 forks source link

How to search for element that contains text in RPA.Windows #1119

Closed revathikanakachalam closed 1 year ago

revathikanakachalam commented 1 year ago

Hi, I am new to windows app automation. We are using RPA.windows library for out app automation. I need to find a element that matches a text in name locator. For example there are few element2 with name value as "Connect to server test1" , "Connect to server test2", "Disconnect from server test3" I need to find elements that matches word "Connect".

Appreciate any help!

mikahanninen commented 1 year ago

Hi @revathikanakachalam .

Here are couple options that can be used for better name attribute matching:

RPA.Windows.Get Element    regex:Connect.*test1    # regular expression matching
RPA.Windows.Get Element    subname:"Connect to"    # inclusive matching
revathikanakachalam commented 1 year ago

@mikahanninen
Both worked, thank you very much

Is there any roadmap in plan to add support for keywords like Wait Until Element Visible, Wait until page contains element, Page should contain element in RPA.Windows library,etc

mikahanninen commented 1 year ago

Windows library keywords already inheritantly wait for an element/window to appear. For example, you could start to execute a Robot that has "Control Window" for a window that does not yet exist, and outside of that execution start the window manually and if there is still timeout left on the "Control Window" it will detect that window exists and takes control of it. The same applies to element-related keywords.

In the RPA context the "Should" type keywords are not really mandatory, but I agree that something like Is Element Visible type of keywords might be usable. There are workarounds that could be used like Get Element with a timeout of 0 and wrapping that into TRY/EXCEPT block.

revathikanakachalam commented 1 year ago

@mikahanninen Thank you that is really helpful

Our application login page elements are not identified by RPA.Windows. When Inspected using Inspect.exe the login page elements has FrameworkId as "Chrome". Where as rest of the pages after login I am able to interact with the elements where the "FrameworkId" is "WPF".

As per info from dev team, web page is integrate inside WPF window

Appreciate any suggestion how to handle the login page

image

cmin764 commented 1 year ago

I haven't used this inspection tool, but maybe you'll have better results with Accessibility Insights. Meanwhile, throw an eye over our How to inspect section of the docs. (so you'd be able to discover more with our windows-record and Print Tree)

You can also try our current Robocorp's Inspector in VSCode:

Screenshot 2023-10-26 at 11 45 16

Read more on Windows Locators

cmin764 commented 1 year ago

Will close this for now as the main problem reported in the initial issue got solved. (~please open a new thread in our forum for similar questions~ (just saw the thread) (and report in GitHub issues/bugs/feature requests given the library))