Can someone help me how to select multiple options(checkbox) in drop down. Need to select option based on the values in excel sheet. In test data sheet comma separated values with partial text would be provided and based on that we need to select the options.
My code:
String[] app=apps.split(",");
for(String apl:app)
{
applications.click();
System.out.println(apl);
WebElement selecapp=MainConfig.getDriver().findElement(By.xpath("//label[contains(.,"+apl+")]"));
selecapp.click();
Thread.sleep(1000);
}
Drop down image from application
HTML Code:
<ul class="dropdown-menu selectItems" id="thisWidth" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 35px, 0px);">
<li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">Test1 -
Test1
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2121 -
Default
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2139 -
acsIVRautomated
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2160 -
ISurvey121
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2176 -
SurveyDemo2
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2177 -
EditedSurvey
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2179 -
TestSurvey234
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2199 -
ForDeletedfgsdh
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2200 -
SurveyReportTest
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2221 -
SurveyDemo25
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2226 -
TestRuleExpression
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2244 -
TestSurvey
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2251 -
dsg
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">A6235 -
A6235
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2253 -
Survey6235
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2254 -
sdgsdg
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2255 -
Testhhh
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2256 -
GGGGGGGGGGGGGGGGGGGGG
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2257 -
dfgdfg
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2258 -
dfgdfhdh
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2259 -
gfhjfgjfg
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2367 -
TestsampleAuto
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2368 -
sampleA1
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2369 -
sampleA12
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2370 -
sampleA13
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2371 -
sampleA15
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2372 -
sampleA16
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2373 -
sampleA17
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2374 -
Nsy5
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2376 -
NSY1
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2381 -
TestsampleAutomationTestsampleAutomationTestsampleAutomationTestsampleAutomationTestsampleAutomation
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2382 -
Te
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2383 -
Te1
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2384 -
Testing123Testing123Testing123Testing123Testing123Testing123Testing123Testing123Testing123Testing123
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2388 -
CyaraHappyPath
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2403 -
SampleTestAutoWithMoreThanLinkText
</label>
</li><li id="app" data-toggle="tooltip" title="">
<label class="dropdown-item">
<input type="checkbox" checked.bind="avl.selected" change.delegate="addAllocation()" id="app" onkeydown="return (event.keyCode!=13);" class="au-target" au-target-id="191">2404 -
Survey2sample
</label>
</li><!--anchor-->
</ul>
</div>
Any help will be really appreciated.
Thanks in advance
I would suggest induce WebDriverWait
and wait for ElementToBeClickable
() and then click.
WebDriverWait wait = new WebDriverWait(MainConfig.getDriver(), TimeSpan.FromSeconds(10));
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath("//label[contains(.,"+apl+")]/input"))).Click();
See if this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.