Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPA.Windows: bubble up errors when Select is attempted on non-existent value #1150

Open
kkotenko opened this issue Feb 9, 2024 · 0 comments

Comments

@kkotenko
Copy link
Contributor

kkotenko commented Feb 9, 2024

Currently, when I accidentally try to Select a value in a ComboBoxControl, and the value is not present, I get no error whatsoever. So I am left with having to check beforehand if the options of the dropdown contain my target value.

In this case, uiautomation does produce a log entry in its own loggers

https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/abb247330bcba4fdb9244f669f451edcab5f4125/uiautomation/uiautomation.py#L7134

and returns False.

However, this message is not bubbled up to me as the user of RPA.Windows, and the return value is not processed:

if hasattr(element.item, "Select"):
# NOTE(cmin764): This is not supposed to work on `*Pattern` or `TextRange`
# objects. (works with `Control`s and its derived flavors only, like a
# combobox)
element.item.Select(
value, simulateMove=self.ctx.simulate_move, waitTime=self.ctx.wait_time
)
else:
raise ActionNotPossible(
f"Element {locator!r} does not support selection (try with"
" `Set Value` instead)"
)

I would provide a PR, but I am not sure myself what the best solution would be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant