如何使用 Selenium 双击这个元素?

How to double click this element using Selenium?

我正在使用以下元素:

<p class="wrap button draggable" id="anonymous_element_1"><b class="icon" id="handler2"></b>Reports</p>

到目前为止我有这个代码:

click_button=driver.find_element_by_xpath('//*[@id="anonymous_element_1"]').click()

如何双击元素?

你试过了吗:

Xyz.click(); Thread.sleep(10); Xyz.click();

?

on the element you can use double_click() method from ActionChains implementation inducing WebDriverWait for the 如下:

ActionChains(driver).double_click(WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//p[@class='wrap button draggable' and @id='anonymous_element_1'][contains(., 'Reports')]")))).perform()

注意:您必须添加以下导入:

from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC