@@ -217,6 +217,38 @@ public virtual Point LocationOnScreenOnceScrolledIntoView
217
217
}
218
218
}
219
219
220
+ /// <summary>
221
+ /// Gets the computed accessible label of this element.
222
+ /// </summary>
223
+ public virtual string ComputedAccessibleLabel
224
+ {
225
+ get
226
+ {
227
+ Dictionary < string , object > parameters = new Dictionary < string , object > ( ) ;
228
+ parameters . Add ( "id" , this . Id ) ;
229
+ Response commandResponse = this . Execute ( DriverCommand . GetComputedAccessibleLabel , parameters ) ;
230
+ return commandResponse . Value . ToString ( ) ;
231
+ }
232
+ }
233
+
234
+ /// <summary>
235
+ /// Gets the computed ARIA role for this element.
236
+ /// </summary>
237
+ public virtual string ComputedAccessibleRole
238
+ {
239
+ get
240
+ {
241
+ // TODO: Returning this as a string is incorrect. The W3C WebDriver Specification
242
+ // needs to be updated to more throughly document the structure of what is returned
243
+ // by this command. Once that is done, a type-safe class will be created, and will
244
+ // be returned by this property.
245
+ Dictionary < string , object > parameters = new Dictionary < string , object > ( ) ;
246
+ parameters . Add ( "id" , this . Id ) ;
247
+ Response commandResponse = this . Execute ( DriverCommand . GetComputedAccessibleRole , parameters ) ;
248
+ return commandResponse . Value . ToString ( ) ;
249
+ }
250
+ }
251
+
220
252
/// <summary>
221
253
/// Gets the coordinates identifying the location of this element using
222
254
/// various frames of reference.
@@ -353,15 +385,15 @@ public virtual void Click()
353
385
}
354
386
355
387
/// <summary>
356
- /// Gets the value of the specified attribute for this element.
388
+ /// Gets the value of the specified attribute or property for this element.
357
389
/// </summary>
358
- /// <param name="attributeName">The name of the attribute.</param>
359
- /// <returns>The attribute's current value. Returns a <see langword="null"/> if the
360
- /// value is not set.</returns>
390
+ /// <param name="attributeName">The name of the attribute or property .</param>
391
+ /// <returns>The attribute's or property's current value. Returns a <see langword="null"/>
392
+ /// if the value is not set.</returns>
361
393
/// <remarks>The <see cref="GetAttribute"/> method will return the current value
362
- /// of the attribute, even if the value has been modified after the page has been
363
- /// loaded. Note that the value of the following attributes will be returned even if
364
- /// there is no explicit attribute on the element:
394
+ /// of the attribute or property , even if the value has been modified after the page
395
+ /// has been loaded. Note that the value of the following attributes will be returned
396
+ /// even if there is no explicit attribute on the element:
365
397
/// <list type="table">
366
398
/// <listheader>
367
399
/// <term>Attribute name</term>
@@ -384,6 +416,9 @@ public virtual void Click()
384
416
/// <description>Input and other UI elements</description>
385
417
/// </item>
386
418
/// </list>
419
+ /// The method looks both in declared attributes in the HTML markup of the page, and
420
+ /// in the properties of the elemnt as found when accessing the element's properties
421
+ /// via JavaScript.
387
422
/// </remarks>
388
423
/// <exception cref="StaleElementReferenceException">Thrown when the target element is no longer valid in the document DOM.</exception>
389
424
public virtual string GetAttribute ( string attributeName )
@@ -414,14 +449,60 @@ public virtual string GetAttribute(string attributeName)
414
449
return attributeValue ;
415
450
}
416
451
452
+ /// <summary>
453
+ /// Gets the value of a declared HTML attribute of this element.
454
+ /// </summary>
455
+ /// <param name="attributeName">The name of the HTML attribugte to get the value of.</param>
456
+ /// <returns>The HTML attribute's current value. Returns a <see langword="null"/> if the
457
+ /// value is not set or the declared attribute does not exist.</returns>
458
+ /// <exception cref="StaleElementReferenceException">Thrown when the target element is no longer valid in the document DOM.</exception>
459
+ /// <remarks>
460
+ /// As opposed to the <see cref="GetAttribute(string)"/> method, this method
461
+ /// only returns attriibutes decalred in the element's HTML markup. To access the value
462
+ /// of an IDL property of the element, either use the <see cref="GetAttribute(string)"/>
463
+ /// method or the <see cref="GetDomProperty(string)"/> method.
464
+ /// </remarks>
465
+ public virtual string GetDomAttribute ( string attributeName )
466
+ {
467
+ string attributeValue = string . Empty ;
468
+ Dictionary < string , object > parameters = new Dictionary < string , object > ( ) ;
469
+ parameters . Add ( "id" , this . Id ) ;
470
+ parameters . Add ( "name" , attributeName ) ;
471
+
472
+ Response commandResponse = this . Execute ( DriverCommand . GetElementAttribute , parameters ) ;
473
+ if ( commandResponse . Value == null )
474
+ {
475
+ attributeValue = null ;
476
+ }
477
+ else
478
+ {
479
+ attributeValue = commandResponse . Value . ToString ( ) ;
480
+ }
481
+
482
+ return attributeValue ;
483
+ }
484
+
417
485
/// <summary>
418
486
/// Gets the value of a JavaScript property of this element.
419
487
/// </summary>
420
- /// <param name="propertyName">The name JavaScript the JavaScript property to get the value of.</param>
488
+ /// <param name="propertyName">The name of the JavaScript property to get the value of.</param>
421
489
/// <returns>The JavaScript property's current value. Returns a <see langword="null"/> if the
422
490
/// value is not set or the property does not exist.</returns>
423
491
/// <exception cref="StaleElementReferenceException">Thrown when the target element is no longer valid in the document DOM.</exception>
492
+ [ Obsolete ( "Use the GetDomProperty method instead." ) ]
424
493
public virtual string GetProperty ( string propertyName )
494
+ {
495
+ return this . GetDomProperty ( propertyName ) ;
496
+ }
497
+
498
+ /// <summary>
499
+ /// Gets the value of a JavaScript property of this element.
500
+ /// </summary>
501
+ /// <param name="propertyName">The name of the JavaScript property to get the value of.</param>
502
+ /// <returns>The JavaScript property's current value. Returns a <see langword="null"/> if the
503
+ /// value is not set or the property does not exist.</returns>
504
+ /// <exception cref="StaleElementReferenceException">Thrown when the target element is no longer valid in the document DOM.</exception>
505
+ public virtual string GetDomProperty ( string propertyName )
425
506
{
426
507
string propertyValue = string . Empty ;
427
508
Dictionary < string , object > parameters = new Dictionary < string , object > ( ) ;
0 commit comments