如何在selenium-python中为angularjs应用程序选择多选下拉列表

时间:2018-03-27 19:07:10

标签: python selenium

我的应用是angularjs。有一个下拉列表支持下拉列表中的多选。单击项目find_element_by_link_text不起作用。 在一个项目上单击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()

错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python36_64\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Python36_64\lib\site-packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
return self._parent.execute(command, params)
File "C:\Python36_64\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "C:\Python36_64\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: 

0 个答案:

没有答案