简体   繁体   English

Select 基于 excel 使用 selenium Z2567A5EC9705EB71AC2C98403E 驱动程序的数据的多个下拉选项

[英]Select multiple drop down options based on the data from excel using selenium web driver

Can someone help me how to select multiple options(checkbox) in drop down.有人可以帮我如何在下拉菜单中选择 select 多个选项(复选框)。 Need to select option based on the values in excel sheet.需要 select 选项基于 excel 表中的值。 In test data sheet comma separated values with partial text would be provided and based on that we need to select the options.在测试数据表中,将提供带有部分文本的逗号分隔值,并基于此我们需要 select 选项。

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: HTML 代码:

                            <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并等待ElementToBeClickable () 然后单击。

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.看看这是否有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium Web驱动程序通过从Excel工作表中读取下拉值来从下拉菜单中选择数据 - Selenium Web driver select data from drop down by reading drop down value from excel sheet 无法在Goibibo网站的Selenium Web Driver下拉列表中选择值 - Unable to select the value in the drop down in selenium Web Driver for the website Goibibo 如何在Selenium Web驱动程序中选择下拉框 - how to select the drop down box in selenium web driver 如何在带有Java的Selenium Web驱动程序中使用xml在下拉列表中随机选择一个值 - how to select a value in drop down randomly using xml in selenium web driver with Java 硒驱动器-从下拉列表中选择所需的锂项目 - Selenium driver - select the desired li item from a drop down list 如何使用硒从下拉列表中进行选择 - How to select from the drop down using Selenium 我无法使用 Java 驱动程序通过 selenium web 驱动程序从 Amazon.ca 页面打开“全部”下拉菜单 - I'm not able to open “All” drop down from Amazon.ca page through selenium web driver using Java 如何在selenium Web驱动程序和testNG中使用数据提供程序读取Excel并获取多个值并将其连接 - How to read an excel and fetch multiple values and concatenate them using data-provider in selenium web driver and testNG 如何使用Selenium Web驱动程序(IE11)基于标签从下拉列表中选择值-Java - How to select value from dropdown based on labels using Selenium Web driver(IE11)-Java 如何在Java中使用TestNG使用Selenium Web驱动程序从2张相同的Excel文档中读取数据 - How to Read the data from 2 sheets of same Excel document using Selenium Web driver using TestNG in Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM