如何在selenium-python中对angularjs应用程序中的多重下拉框进行选择

2024-04-24 02:37:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我的申请是angularjs。有一个下拉列表支持从下拉列表中选择多个选项。单击项目“按链接文本查找元素”不起作用。 在一个项目上单击xpath也不起作用。单击一次后,将打开下拉列表,显示列表中的所有项目。我只需要点击列表中名为ACCUWAN的项目。有没有办法点击它?在

<div class="aots-multi-select form-control" parent-id="6bc2f28b-7df6-4b62-  b0d7-6876b1f23c0a" ng-disabled="disabled" ng-class="{'errFieldBorder':  errorField}" tabindex="0" style="position: absolute; left: 126px; top: 327.4px; width: 254.617px; z-index: 999999;">
<div ng-if="aotsMultiSelectItems != ' '" popover="" popover-class="myaots-popover-class" popover-trigger="mouseenter" popover-append-to-body="true" popover-enable="(!disablePopover || textOverflows())">
<span class="icon">
<ul class="dropdown-menu multi-dropdown-menu multiselect-focus show" aria-labelledby="multiDropdownMenu" child-id="6bc2f28b-7df6-4b62-b0d7-6876b1f23c0a" style="position:absolute !important; width:255px !important;left:-1px !important;top:-230px; border-radius: 4px 4px 0px 0px;">
<li data-ng-class="setBgClass(option)" data-ng-repeat="option in optionsLocal">
 <a class="select-option focus-0" key="accuwan_key" data-ng-click="toggleSelectItem(option)" tabindex="-1" list-index="0">
 <span aria-hidden="true"/>
    ACCUWAN
    </a>
 </li>

driver.find_element_by_xpath("//div[@id='functionalAreaDIV']/myaots-multi-select/div/div/span/i[2]").click() ==> This command works and opens the drop down and displays the list.
time.sleep(3) # To Avoid any race condition
driver.find_element_by_link_text("ACCUWAN").click()

错误:

^{2}$

Tags: 项目divid列表datangselectmulti