【发布时间】:2019-11-21 14:51:29
【问题描述】:
我对 Selenium 比较陌生,我正在开发一个网络浏览器自动化项目,其中一个操作是从下拉菜单中选择一个元素,请在 html 代码下方找到。
<span id="export_menu" class="ui-button drop-down export-menu" tabindex="0" role="application">
<span class="menu_text">Export</span>
<span class="drop-down-menu ui-icon ui-icon-triangle-1-s"></span>
<ul class="export-actions"><li><header>Export Report</header>
<ul><li class="menu-action"><input type="button" value="CSV" class="button ui-button ui-widget ui-state-default ui-corner-all" id="export_csv" data-format="csv" role="button" aria-disabled="false"></li></ul>
<ul><li class="menu-action"><input type="button" value="PDF" class="button ui-button ui-widget ui-state-default ui-corner-all" id="export_pdf" data-format="pdf" role="button" aria-disabled="false"></li></ul>
<ul><li class="menu-action"><input type="button" value="Schedule Export" class="button ui-button ui-widget ui-state-default ui-corner-all" id="schedule" role="button" aria-disabled="false"></li></ul></li></ul>
</ul>
</span>
我在 Python 上尝试了以下操作,错误如下
driver.find_element_by_id("export_menu").click()
driver.find_element_by_id("export_csv").click()
selenium.common.exceptions.ElementNotInteractableException:消息:元素无法滚动到视图中
经过一些研究,我也尝试了以下操作,这只是 超时
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="export_csv"]'))).click()
请求帮助!
【问题讨论】:
标签: python selenium-webdriver xpath css-selectors webdriverwait