Home > Software engineering >  How to double click this element using Selenium?
How to double click this element using Selenium?

Time:04-22

I am working with the following element:

<p  id="anonymous_element_1"><b  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?

CodePudding user response:

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

CodePudding user response:

Did you try:

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

?

  • Related