首页 > 解决方案 > 如何单击带有 python selenium 的链接

问题描述

我正在尝试使用 click() 单击此链接:

<a id="export-button" class="pull-right" @click="exportFile('/en/my-investments/list.xlsx')">
    <i class="fa fa-file-excel-o"></i> Download Selected List
</a>

但它说该元素不可点击......有什么想法吗?

标签: pythonselenium-webdriver

解决方案


您可以使用动作类来单击您的元素,

from selenium.webdriver import ActionChains

actions = ActionChains(driver)
actions.move_to_element(driver.find_element_by_xpath("//a[@id='export-button']")).click().perform()

推荐阅读