@@ -891,26 +891,21 @@ public void xpathShouldMatchXTimes(String xpath, int expectedXpathCount, String.
891
891
logLevel );
892
892
}
893
893
894
- @ RobotKeyword ("Click to First Item from List Items by Locator." )
895
- @ ArgumentNames ({"locator" , "childLocator=NONE" , "message=NONE" })
896
- public void clickToFirstItem (String locator , String ... params ) {
897
- String childLocator = robot .getParamsValue (params , 0 , "" );
898
- String message = robot .getParamsValue (params , 1 , "" );
899
- List <WebElement > elements = browserManagement .getCurrentWebDriver ().findElements (By .xpath (locator ));
900
- if (elements .isEmpty ()) {
901
- if (message .isEmpty ()) {
902
- message = String .format ("The Element was not found by locator '%s' and child locator '%s'." ,
903
- locator , childLocator );
904
- }
905
- throw new SeleniumLibraryNonFatalException (message );
906
- }
907
- WebElement element = elements .get (0 );
908
- if (!childLocator .isEmpty ()) {
909
- element .findElements (By .xpath (childLocator )).get (0 ).click ();
910
- } else {
911
- element .click ();
912
- }
913
- }
894
+ @ RobotKeyword ("Click to element from list elements by locator ``xpath``." )
895
+ @ ArgumentNames ({"xpath" , "index=0" , "message=NONE" })
896
+ public void clickElementByIndex (String xpath , String ... params ) {
897
+ String message = robot .getParamsValue (params , 0 , "" );
898
+ int index = robot .getParamsValue (params , 1 , 0 );
899
+ List <WebElement > elements = elementFind (xpath , false , false );
900
+ if (elements .isEmpty ()) {
901
+ if (message .isEmpty ()) {
902
+ message = String .format ("The Element was not found by locator '%s' with index '%d'" , xpath , index );
903
+ }
904
+ throw new SeleniumLibraryNonFatalException (message );
905
+ }
906
+ WebElement element = elements .get (index );
907
+ element .click ();
908
+ }
914
909
915
910
// ##############################
916
911
// Internal Methods
0 commit comments