Double Click operation

double_click() Method:

This method performs double-click operation on an element.

Example:

  • Import the ActionChains Class
  • Launch the webpage "http://www.dummypoint.com/Actions.html"
  • Create the object for ActionChains class
  • Call the Double click Operation on required WebElement
  • Wait for 5 sec.
  • Close the Web Browser


Double_Click.py

from selenium import webdriver
from selenium.common.exceptions import ElementNotVisibleException, NoSuchElementException
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
import time

driver = webdriver.Chrome("/Users/admin/Documents/Skill2Lead/Others/drivers/chromedriver.exe")

driver.get("http://www.dummypoint.com/Actions.html")
assert "Selenium Template" in driver.title
time.sleep(2)

wait = WebDriverWait(driver, 25, poll_frequency=1,
                     ignored_exceptions=[ElementNotVisibleException, NoSuchElementException])

ele = wait.until(ec.presence_of_element_located((By.LINK_TEXT,"Form")))

# Import the ActionChains Class
# 1. Create the object for ActionChains class
actions = ActionChains(driver)

# 2. Call the Double click Operation on required WebElement
actions.double_click(ele).perform()


time.sleep(5)
driver.quit()