通过硒从aria下拉框中选择一个元素

时间:2019-07-01 17:48:40

标签: selenium wai-aria

我正在尝试构建一个Web抓取器,以从保管箱中一个接一个地选择所有元素,然后从后续结果中抓取数据。但是,我无法通过aria下拉菜单进行交互。

我尝试选择输入框,然后通过xpath选择下拉列表,但这似乎不起作用。

        datacenter = "Boydton 5"
        elem = WebDriverWait(driver, 30).until(
            EC.presence_of_element_located((By.XPATH, "//*[@id='pageContent']/div/div/div[1]/div/shared-blade/div/div[1]/div/div/div/dc-picker/div/div[2]/input"))
        )
        print(elem)

        elem.click()


        #Select from dropdown
        elem = WebDriverWait(driver, 30).until(
            EC.presence_of_element_located((By.XPATH, "//*[@id=typeahead-31-8093']"))
        )
        elem.send_keys(datacenter)

输入框代码:

<input type="text" placeholder="Data Center" ng-  model="$ctrl.selectedDatacenterName" uib-typeahead="::datacenterAndColo as ::datacenterAndColos.DataCenter.name for datacenterAndColos in ::$ctrl.dcColoCatalogList | filter:$viewValue" class="form-control ng-pristine ng-valid ng-empty ng-touched" typeahead-min-length="0" typeahead-select-on-exact="true" typeahead-on-select="$ctrl.onDcSelection($item, $model, $label, $event)" ng-disabled="$ctrl.isLoading" aria-autocomplete="list" aria-expanded="false" aria-owns="typeahead-31-2065" style="">

下拉列表代码:

<ul class="dropdown-menu ng-isolate-scope ng-hide" ng-show="isOpen() &amp;&amp; !moveInProgress" ng-style="{top: position().top+'px', left: position().left+'px'}" role="listbox" aria-hidden="true" uib-typeahead-popup="" id="typeahead-31-2065" matches="matches" active="activeIdx" select="select(activeIdx, evt)" move-in-progress="moveInProgress" query="query" position="position" assign-is-open="assignIsOpen(isOpen)" debounce="debounceUpdate" style="top: 36px; left: 0px;">
    <!-- ngRepeat: match in matches track by $index -->
</ul>

0 个答案:

没有答案