@@ -100,6 +100,13 @@ public class WdElement extends TaggableBase implements Serializable {
100100 public long naturalWidth , naturalHeight ;
101101 public long displayedWidth , displayedHeight ;
102102
103+ // Web aria properties
104+ public String ariaLabel , ariaLabelledBy , ariaDescribedBy , ariaRole , ariaChecked , ariaInvalid ;
105+ public String ariaCurrent , ariaHasPopup , ariaControls , ariaLive ;
106+ public String ariaValueNow , ariaValueMin , ariaValueMax , ariaValueText ;
107+ public Boolean ariaDisabled , ariaHidden , ariaExpanded , ariaPressed , ariaSelected ;
108+ public Boolean ariaRequired , ariaReadOnly , ariaBusy , ariaModal ;
109+
103110 public transient RemoteWebElement remoteWebElement ; // Reference to the remote Web Element
104111
105112 public transient Map <String , String > attributeMap ;
@@ -152,6 +159,30 @@ public WdElement(Map<String, Object> packedElement, WdRootElement root, WdElemen
152159 visibility = (packedElement .get ("visibility" ) == null ) ? "" : (String ) packedElement .get ("visibility" );
153160 xpath = (packedElement .get ("xpath" ) == null ) ? "" : (String ) packedElement .get ("xpath" );
154161
162+ ariaLabel = getAttribute ("aria-label" );
163+ ariaLabelledBy = getAttribute ("aria-labelledby" );
164+ ariaDescribedBy = getAttribute ("aria-describedby" );
165+ ariaRole = getAttribute ("role" );
166+ ariaDisabled = parseBoolean (getAttribute ("aria-disabled" ));
167+ ariaHidden = parseBoolean (getAttribute ("aria-hidden" ));
168+ ariaExpanded = parseBoolean (getAttribute ("aria-expanded" ));
169+ ariaPressed = parseBoolean (getAttribute ("aria-pressed" ));
170+ ariaSelected = parseBoolean (getAttribute ("aria-selected" ));
171+ ariaChecked = getAttribute ("aria-checked" );
172+ ariaRequired = parseBoolean (getAttribute ("aria-required" ));
173+ ariaInvalid = getAttribute ("aria-invalid" );
174+ ariaReadOnly = parseBoolean (getAttribute ("aria-readonly" ));
175+ ariaCurrent = getAttribute ("aria-current" );
176+ ariaHasPopup = getAttribute ("aria-haspopup" );
177+ ariaControls = getAttribute ("aria-controls" );
178+ ariaLive = getAttribute ("aria-live" );
179+ ariaBusy = parseBoolean (getAttribute ("aria-busy" ));
180+ ariaModal = parseBoolean (getAttribute ("aria-modal" ));
181+ ariaValueNow = getAttribute ("aria-valuenow" );
182+ ariaValueMin = getAttribute ("aria-valuemin" );
183+ ariaValueMax = getAttribute ("aria-valuemax" );
184+ ariaValueText = getAttribute ("aria-valuetext" );
185+
155186 try {
156187 maxLength = Integer .valueOf (attributeMap .getOrDefault ("maxlength" , "-1" ));
157188 } catch (NumberFormatException e ) {
@@ -245,11 +276,11 @@ public String getElementDescription() {
245276 else if (hasText (textContent )) {
246277 semanticDescription = normalizeDescription (textContent );
247278 }
248- else if (hasText (getAttribute ( "aria-label" ) )) {
249- semanticDescription = normalizeDescription (getAttribute ( "aria-label" ) );
279+ else if (hasText (ariaLabel )) {
280+ semanticDescription = normalizeDescription (ariaLabel );
250281 }
251- else if (hasText (getAttribute ( "aria-labelledby" ) )) {
252- semanticDescription = normalizeDescription (getAttribute ( "aria-labelledby" ) );
282+ else if (hasText (ariaLabelledBy )) {
283+ semanticDescription = normalizeDescription (ariaLabelledBy );
253284 }
254285 else if (hasText (placeholder )) {
255286 semanticDescription = normalizeDescription (placeholder );
@@ -299,6 +330,15 @@ private String getAttribute(String key) {
299330 return (attributeMap == null ) ? "" : attributeMap .getOrDefault (key , "" );
300331 }
301332
333+ private Boolean parseBoolean (String value ) {
334+ if (value == null ) return null ;
335+ String normalized = value .trim ().toLowerCase ();
336+ if (normalized .isEmpty ()) return null ;
337+ if (normalized .equals ("true" )) return true ;
338+ if (normalized .equals ("false" )) return false ;
339+ return null ;
340+ }
341+
302342 private void setName () {
303343 if (name == null || name .equals ("null" ) || name .isEmpty ()) {
304344 name = textContent ;
0 commit comments