Rule #1: Life is supposed to be fun!

September 23, 2021

How to perform triple click on Selenium with Python

I will go straight to the point. This is the piece of code that help you to perform triple click into any element by using Selenium on Python.

In the code below, I find the H1 element on my page, and then perform triple click on it

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Chrome()
driver.get(“https://vutung.com/2019/08/23/how-to-use-timer-in-gtm-to-track-real-time-on-page/”)

triple_click_element = driver.find_elements_by_tag_name(‘h1’)[1]
actions = ActionChains(driver)
for i in range(3):
actions.move_to_element(triple_click_element).click()
actions.perform()

You can try to change the find_element_by… function with any other function that suit your needs

How to triple click on Selenium with Python

Posted in Python
Write a comment