java - Search for elements with same class names in webdriver -
i need write script drop-down boxes. there 2 dropdown elements on same screen , both dropdown boxes have got similar class names (dropdown boxes of search , select kind),and there no unique-id element. script works fine select element first dropdown, fails when supposed perform same second dropdown.
do reply
regards
<div class="title-edit-form" id="49156080-2097-ea0f"> <div class="control-group required"> <label class="control-label">title </label> <div class="controls row-fluid"> <div class="select2-container span12 select2-container-active select2-dropdown-open" id="s2id_title"> <a href="#" onclick="return false;" class="select2-choice" tabindex="-1"> <span>de</span> <abbr class="select2-search-choice-close" style="display:none;"> </abbr> <div> <b></b> </div> </a> </div> <input class="span12" id="title" type="hidden" style="display: none;" value="-1"> </div> </div> <div class="select2-drop select2-drop-active" style="display: block; top: 177px; left: 536px; width: 530px;"> <div class="select2-search"> <input type="text" autocomplete="off" class="select2-input select2-focused" tabindex="-1" style=""> </div> <ul class="select2-results"> <li class="select2-results-dept-0 select2-result select2-result-selectable select2-new"> <div class="select2-result-label"> <span class="select2-match">de</span> </div> </li> <li class="select2-results-dept-0 select2-result select2-result-selectable"> <div class="select2-result-label"> <span class="select2-match">de</span> "an" </div> </li> <li class="select2-results-dept-0 select2-result select2-result-selectable select2-highlighted"> <div class="select2-result-label"> "stu" <span class="select2-match">de</span> "nt" </div>`enter code here` </li> </ul> </div>
the best way use cssselector() kind of things, , nth-child() function cssselector().
exemple :
// gets first div contains school class value. driver.findelement(by.cssselector("div.school:nth-child(1)"));
Comments
Post a Comment