@@ -429,18 +429,32 @@ public void elementTextShouldNotBe(String locator, String text, String...params)
429
429
"\r \n " +
430
430
"The ``attribute_locator`` consists of element locator followed by an @ sign and attribute name. Example: element_id@class\r \n " +
431
431
"\r \n " +
432
- "Key attributes for arbitrary elements are id and name. See `Introduction` for details about locators." )
432
+ "Key attributes for arbitrary elements are id and name. See `Introduction` for details about locators.\r \n " +
433
+ "\r \n " +
434
+ "Passing attribute name as part of the locator was removed in SeleniumLibrary 3.2. The explicit attribute argument should be used instead." )
433
435
@ ArgumentNames ({ "attributeLocator" })
436
+ @ Deprecated
434
437
public String getElementAttribute (String attributeLocator ) {
435
438
String [] parts = parseAttributeLocator (attributeLocator );
439
+ return getElementAttribute (parts [0 ], parts [1 ]);
440
+ }
436
441
437
- List <WebElement > elements = elementFind (parts [0 ], true , false );
442
+ @ RobotKeyword ("Returns value of attribute from element locator.\r \n " +
443
+ "\r \n " +
444
+ "See the `Locating elements` section for details about the locator syntax.\r \n " +
445
+ "\r \n " +
446
+ "Example: ${id}= Get Element Attribute css:h1 id\r \n " +
447
+ "\r \n " +
448
+ "Passing attribute name as part of the locator was removed in SeleniumLibrary 3.2. The explicit attribute argument should be used instead." )
449
+ @ ArgumentNames ({ "locator" , "attribute" })
450
+ public String getElementAttribute (String locator , String attribute ) {
451
+
452
+ List <WebElement > elements = elementFind (locator , true , false );
438
453
439
454
if (elements .size () == 0 ) {
440
- throw new SeleniumLibraryNonFatalException (String .format ("Element '%s' not found." , parts [ 0 ] ));
455
+ throw new SeleniumLibraryNonFatalException (String .format ("Element '%s' not found." , locator ));
441
456
}
442
-
443
- return elements .get (0 ).getAttribute (parts [1 ]);
457
+ return elements .get (0 ).getAttribute (attribute );
444
458
}
445
459
446
460
@ RobotKeyword ("Clears the text from element identified by ``locator``.\r \n " +
0 commit comments