13
13
import org .openqa .selenium .WebDriver ;
14
14
import org .openqa .selenium .WebElement ;
15
15
import org .openqa .selenium .interactions .Actions ;
16
- import org .robotframework .javalib .annotation .ArgumentNames ;
17
- import org .robotframework .javalib .annotation .Autowired ;
18
- import org .robotframework .javalib .annotation .RobotKeyword ;
19
- import org .robotframework .javalib .annotation .RobotKeywords ;
16
+ import org .robotframework .javalib .annotation .*;
20
17
21
18
import com .github .markusbernhardt .seleniumlibrary .RunOnFailureKeywordsAdapter ;
22
19
import com .github .markusbernhardt .seleniumlibrary .SeleniumLibraryNonFatalException ;
@@ -423,17 +420,9 @@ public void elementTextShouldNotBe(String locator, String text, String...params)
423
420
}
424
421
}
425
422
426
- @ RobotKeyword ("Returns the value of an element attribute.\r \n " +
427
- "\r \n " +
428
- "The ``attribute_locator`` consists of element locator followed by an @ sign and attribute name. Example: element_id@class\r \n " +
429
- "\r \n " +
430
- "Key attributes for arbitrary elements are id and name. See `Introduction` for details about locators.\r \n " +
431
- "\r \n " +
432
- "Passing attribute name as part of the locator was removed in SeleniumLibrary 3.2. The explicit attribute argument should be used instead." )
433
- @ ArgumentNames ({ "attributeLocator" })
434
- @ Deprecated
435
- public String getElementAttribute (String attributeLocator ) {
436
- String [] parts = parseAttributeLocator (attributeLocator );
423
+ @ RobotKeywordOverload
424
+ public String getElementAttribute (String locator ) {
425
+ String [] parts = parseAttributeLocator (locator );
437
426
return getElementAttribute (parts [0 ], parts [1 ]);
438
427
}
439
428
@@ -444,14 +433,15 @@ public String getElementAttribute(String attributeLocator) {
444
433
"Example: ${id}= Get Element Attribute css:h1 id\r \n " +
445
434
"\r \n " +
446
435
"Passing attribute name as part of the locator was removed in SeleniumLibrary 3.2. The explicit attribute argument should be used instead." )
447
- @ ArgumentNames ({ "locator" , "attribute" })
448
- public String getElementAttribute (String locator , String attribute ) {
436
+ @ ArgumentNames ({ "locator" , "attribute=None" })
437
+ public String getElementAttribute (String locator , String ... attribute ) {
438
+ String attributeName = robot .getParamsValue (attribute , 0 , "None" );
449
439
List <WebElement > elements = elementFind (locator , true , false );
450
440
451
441
if (elements .size () == 0 ) {
452
442
throw new SeleniumLibraryNonFatalException (String .format ("Element '%s' not found." , locator ));
453
443
}
454
- return elements .get (0 ).getAttribute (attribute );
444
+ return elements .get (0 ).getAttribute (attributeName );
455
445
}
456
446
457
447
@ RobotKeyword ("Clears the text from element identified by ``locator``.\r \n " +
0 commit comments