1

I am working with the following element:

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

I have this code so far:

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

How can I double click on the element?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

2 Answers2

1

To double_click on the element you can use double_click() method from ActionChains implementation inducing WebDriverWait for the element_to_be_clickable() as follows:

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()

Note : You have to add the following imports :

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
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • When I run the above code I receive the following error: NameError: name 'ActionChains' is not defined I have the following imports in my code so far: from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium import webdriver from selenium.webdriver.chrome.options import Options –  Apr 21 '22 at 20:09
  • @HamidBee Checkout the updated answer and let me know the status. – undetected Selenium Apr 21 '22 at 20:11
0

Did you try:

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

?

David Weber
  • 173
  • 9