Skip to content

Instantly share code, notes, and snippets.

@jimmykhlam
jimmykhlam / gist:1396394
Created November 26, 2011 22:18
Modifying jQuery mousehold event plugin to pass through original mousedown event
/*
* jQuery mousehold plugin - fires an event while the mouse is clicked down.
* Additionally, the function, when executed, is passed a single
* argument representing the count of times the event has been fired during
* this session of the mouse hold.
*
* @author Remy Sharp (leftlogic.com)
* @date 2006-12-15
* @example $("img").mousehold(200, function(i){ })
* @desc Repeats firing the passed function while the mouse is clicked down
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.action_chains import ActionChains
from datetime import datetime
list_chat_groups_test = [
'TestGroup01',
'TestGroup02',
'TestGroup03',
'TestGroup04',
'TestGroup05',
'TestGroup06',
'TestGroup07',
'TestGroup08',
'TestGroup09',
#define a helper function
def click_modal_button(button_text):
modal_button = WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.XPATH, "//div[@data-animate-modal-body='true']//div[@role='button']//div[text() = '%s']" % (button_text))))
modal_button.click()
#define a function that adds contact_to_add to group_name
def add_contact_to_group(group_name, contact_to_add):
#find chat with the correct title
el_target_chat = WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.XPATH, "//span[@title='%s']" % (group_name))))
el_target_chat.click()