I'm new selenium webdriver using Java. I'm able write java code to select dropdown if it has normal select class something like :-
new Select(driver.findElement(By.id("someid"))).selectByValue("1"));
But below code has select2 class from jquery. Tried multiple options. I can select to show dropdown by from then, I couldn't select Apple or orange, or select grape.
can some one please help me on how to select Apple from this kind of dropdown list? Any clue or code is much appreciated. ..
this is how code looks like
<div id="select2-drop" class="select2-drop select2-display-none select2-with-searchbox select2-drop-active" style="somestyleelements">
<div class="select2-search">
<ul id="select2-results-1" class="select2-results" role="listbox">
<li class="select2-results-dept-0 select2-result select2-result-selectable select2-highlighted" role="presentation">
<div id="select2-result-label-random" class="select2-result-label" role="option">
<span class="select2-match"></span>
Apples
</div>
</li>
<li class="select2-results-dept-0 select2-result select2-result-selectable" role="presentation">
<div id="select2-result-label-random" class="select2-result-label" role="option">
<span class="select2-match"></span>
Orange
</div>
<li class="select2-results-dept-0 select2-result select2-result-selectable" role="presentation">
<li class="select2-results-dept-0 select2-result select2-result-selectable" role="presentation">
<li class="select2-results-dept-0 select2-result select2-result-selectable" role="presentation">
</ul>
</div>
Thanks in advance