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

NVDAObjects/UIA: add UIAAutomationId getter #11447

Merged

Conversation

josephsl
Copy link
Collaborator

@josephsl josephsl commented Aug 2, 2020

Link to issue number:

Fixes #11445

Summary of the issue:

Due to timing errors (perhaps NVDA tries to fetch UIA element information before theelement is truly ready), COM error is raised, particularly more so when trying to obtain Automation Id when modern keyboard opens.

Description of how this pull request fixes the issue:

Adds UIAAutomationId getter to UIA NVDA object class. This will query the current Automation Id property for an element, returning the current value or an empty if no issues occur or an exception occurs, respectively. Along iwth this, edited find overlay classes method to use a local record of Automation Id to reduce attribute access.

Testing performed:

Tested:

  1. Opening modern keyboard.
  2. Obtaining Automation Id for Start search box in Windows 10.
  3. Navigating within File Explorer.
  4. Using Settings app and other Windows 10 apps.

Known issues with pull request:

If an element is destroyed, Automation Id property returns an empty string (observed after opening NVDA Python Console while focused on Start search box). This is a non-issue unless a developer is really interested in looking at Automation Id and somehow work with it while playing around in Python Console (a better way would be looking at developer info for navigator object). Also, for modern keyboard, this will allow NVDA to observe state change and UIA item selected events in more cases, especially if an emoji is selected when opening emoji panel a second time (modern keyboard issues will be dealt separately, which will involve rewriting event handlers).

Change log entry:

None needed.

.

Sometimes a COM error is raised when trying to obtain cached automation Id, particularly if a UIA element isn't ready yet (for example, in modern keyboard). To avoid COM error, introduce a dedicated UIA Automation Id getter that either returns the Automation Id if found or an empty string. The overall structure is based on UIAFullDescription and UIAHelpText getters.
…old current Id information. Re nvaccess#11445.

When going through overlay classes, instead of fetching cached Automation Id from the underlying UIA element, use the current Automation Id as returned by what U*IA actually says (based on new Automation Id getter). This reduces attribute access and removes the need for a try/except block for some cases as either the actual Automation Id or an empty string will be recorded. However, for backward compatibility, some notable try/except blocks such as search field checks will remain.
@codeofdusk
Copy link
Contributor

codeofdusk commented Aug 3, 2020

unless a developer is really interested in looking at Automation Id and somehow work with it while playing around in Python Console

I do this when exploring new UIA interfaces.

@josephsl
Copy link
Collaborator Author

josephsl commented Aug 3, 2020 via email

@michaelDCurran michaelDCurran merged commit 3c35b91 into nvaccess:master Aug 3, 2020
@nvaccessAuto nvaccessAuto added this to the 2020.3 milestone Aug 3, 2020
@josephsl josephsl deleted the i11445UIAutomationIdProperty branch August 10, 2020 04:09
feerrenrut pushed a commit that referenced this pull request Feb 16, 2022
…13125)

Closes #11483 

Summary:
As part of #11445 discussion, a UIAAutomationId getter was introduced (PR #11447) to UIA NVDA object class in NVDA 2020.3. 
Subsequent UIA work uses UIAAutomationId property but it wasn't expanded to cover all NVDA source code.

Description of change:
Converts obj.UIAElement.cachedAutomationId call to use obj.UIAAutomationId.
obj.UIAAutomationId fetches current Automation Id string.

All usages of cachedAutomationId are converted except for:
- Excel app module: in one instance, UIA element is fetched and cached Automation Id is obtained directly from the element.
- In NVDAObjects.UIA.UIA, there is one instance where parent UIA element is fetched and cached Automation Id is retrieved from the element directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants