@@ -400,11 +400,39 @@ public void Click()
400
400
/// <exception cref="StaleElementReferenceException">Thrown when the target element is no longer valid in the document DOM.</exception>
401
401
public string GetAttribute ( string attributeName )
402
402
{
403
+ Response commandResponse = null ;
404
+ string attributeValue = string . Empty ;
403
405
Dictionary < string , object > parameters = new Dictionary < string , object > ( ) ;
404
406
parameters . Add ( "id" , this . elementId ) ;
405
407
parameters . Add ( "name" , attributeName ) ;
406
- Response commandResponse = this . Execute ( DriverCommand . GetElementAttribute , parameters ) ;
407
- string attributeValue = string . Empty ;
408
+ if ( this . driver . IsSpecificationCompliant )
409
+ {
410
+ List < string > booleanAttributes = new List < string > ( )
411
+ {
412
+ "default" , "typemustmatch" , "checked" , "defer" , "async" , "muted" ,
413
+ "reversed" , "required" , "controls" , "ismap" , "disabled" , "novalidate" ,
414
+ "readonly" , "allowfullscreen" , "selected" , "formnovalidate" ,
415
+ "multiple" , "autofocus" , "open" , "loop" , "autoplay"
416
+ } ;
417
+
418
+ if ( attributeName == "style" )
419
+ {
420
+ return this . driver . ExecuteScript ( "return arguments[0].style.cssText" , this ) . ToString ( ) ;
421
+ }
422
+
423
+ commandResponse = this . Execute ( DriverCommand . GetElementProperty , parameters ) ;
424
+ if ( ( commandResponse . Value == null ||
425
+ ( ( commandResponse . Value . ToString ( ) == string . Empty || commandResponse . Value . ToString ( ) == bool . FalseString ) && attributeName != "value" ) ) ||
426
+ booleanAttributes . Contains ( attributeName ) )
427
+ {
428
+ commandResponse = this . Execute ( DriverCommand . GetElementAttribute , parameters ) ;
429
+ }
430
+ }
431
+ else
432
+ {
433
+ commandResponse = this . Execute ( DriverCommand . GetElementAttribute , parameters ) ;
434
+ }
435
+
408
436
if ( commandResponse . Value == null )
409
437
{
410
438
attributeValue = null ;
0 commit comments