【发布时间】:2021-08-02 08:35:09
【问题描述】:
我在一个 web 项目中使用了 python selenium,到目前为止它与其他 web 元素完美配合,但是对于这个元素它总是返回 “元素不可交互:元素当前不可见,可能无法操作 (会话信息:chrome=90.0.4430.93)"
我要交互的元素的编码是
<select id="collection-arrangement" name="collectionArrangement" class="form-control ng-dirty ng-valid-parse ng-touched ng-empty ng-invalid ng-invalid-required" required="" ng-model="Bin.CollectionArrangement" ng-change="onCollectionArrangementChange(Bin.CollectionArrangement.id)" ng-options="type as type.value for type in CollectionArrangements track by type.value" aria-invalid="true" style=""><option value="" class="" selected="selected">-- select an option --</option><option label="Site pays for collection " value="Site pays for collection " selected="selected">Site pays for collection </option><option label="Waste Service Provider purchases materials" value="Waste Service Provider purchases materials">Waste Service Provider purchases materials</option><option label="Internal bin not collected by Waste Service Provider" value="Internal bin not collected by Waste Service Provider" selected="selected">Internal bin not collected by Waste Service Provider</option></select>
我的代码是
collection_arrangement = '/html/body/div/div[2]/div/section/div/div[1]/div/section/div[3]/div/div[3]/div/div[3]/section/form/table/tbody/tr[5]/td[1]/div/div/div/select'
wait = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH,collection_arrangement)))
select = Select(driver.find_element_by_id(collection_arrangement))
driver.find_element_by_xpath(collection_arrangement).click()
select.select_by_value('Internal bin not collected by Waste Service Provider')
我想选择“垃圾服务提供商未收集的内部垃圾箱”选项,但每次运行此脚本时,光标直到悬停在最后一个元素上,这意味着无法找到或操纵该元素?
任何想法都非常感谢!
【问题讨论】:
标签: java python selenium web element