java - how to select 2nd button using selenium code if 3 buttons are same -
error when select 1 of them
i have 3 button , wants select 2nd 1 using selenium testing java code
<p> <button class="btn btn-primary pull-right" ng-click="openmediacreator=true">add</button> </p> <p> <button class="btn btn-primary pull-right" ng-click="openmediacreator=true">add</button> </p> <p> <button class="btn btn-primary pull-right" ng-click="openmediacreator=true">add</button> </p>
i use code select 2nd button
public basketdetailsobject addyoutubevideo(string url){ try { getdriver().findelement(by.linktext("add")).click(); } catch (exception e) { system.out.println("there error on add youtube video"+e); } return getfactory().create(basketdetailsobject.class); }
but knw not works please give me wright code that
use this, need ensure have 3 buttons otherwise get(1) may fails or give wrong button.
list<webelement> buttons = getdriver().findelements(by.linktext("add")); buttons.get(1).click();
Comments
Post a Comment