首页 > 解决方案 > Python Selenium - 无法单击具有 HTML 标记 i 类的 UI 元素

问题描述

所有带有 HTML 标签“ i class”的 UI 元素都没有被点击

下面是我试图点击的元素的 HTML:

<button class="btn btn-icon btn-transparent  undefined" eventkey="1"><i class="fa fa-bolt hx-primary inline-actions-overview" title="Test this"></i></button>

我用 css 和 xpaths 尝试了以下各种方法,但似乎没有任何效果:

1.) self.driver.find_element(By.CSS_SELECTOR, '.fa-bolt').click()
2.) ActionChains(self.driver.get_driver()).move_to_element(element).send_keys(Keys.ENTER).perform()
3.) ActionChains(self.driver.get_driver()).move_to_element(element).double_click(element).perform()
4.) self.driver.execute_script("arguments[0].click();", element)

任何帮助表示赞赏!

注意:我需要单击的元素来自以下 HTML:

<i class="fa fa-bolt hx-primary inline-actions-overview" title="Test this"></i>

标签: seleniumselenium-webdriverui-automationbrowser-automation

解决方案


推荐阅读