Topics

get css selector of focused element


Stefan Moisei
 

Hi,
Is it possible to get a css selector for the focused web element?   I tried IA2 attribeutes and iSimpleDomNode, but I only managed to get the class and id. this is not enough, since web devs hardly respect the rule of unique ID’s.
Doing it with js is not reliable either, as, even with nvda+8 turned  off, focus is not always correctly found.
Thanks,
 


Andy B.
 

I never figured out how to get it to work inside of an NVDA addon either. You could try bs4, cssutils, or tinycss. Unfortunately, they all require xml.dom. NVDA excluded it from its Python library for some strange reason, and providing a prebuilt version of xml.etree seems impossible. If you can figure it out, I can continue work on developer toolkit.

 

 

From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Stefan Moisei via groups.io
Sent: Tuesday, November 17, 2020 4:58 PM
To: nvda-addons@nvda-addons.groups.io
Subject: [nvda-addons] get css selector of focused element

 

Hi,

Is it possible to get a css selector for the focused web element?   I tried IA2 attribeutes and iSimpleDomNode, but I only managed to get the class and id. this is not enough, since web devs hardly respect the rule of unique ID’s.

Doing it with js is not reliable either, as, even with nvda+8 turned  off, focus is not always correctly found.

Thanks,