在python中双击selenium

在python中双击selenium,python,selenium,double-click,Python,Selenium,Double Click,我将selenium与python一起使用。我可以让下面的代码点击我想要的地方,但我希望它dbl点击。我不是很好的行动链,我知道我需要为dbl点击。有人能帮我改变一下吗 user = self.find_element_by_id("selUsers") for option in user.find_elements_by_tag_name("option"): if option.text == "Admin, Ascender": option.click()

我将selenium与python一起使用。我可以让下面的代码点击我想要的地方,但我希望它dbl点击。我不是很好的行动链,我知道我需要为dbl点击。有人能帮我改变一下吗

user = self.find_element_by_id("selUsers")
for option in user.find_elements_by_tag_name("option"):
    if option.text == "Admin, Ascender":
         option.click()

据我所知,动作链是唯一最好的选择

from selenium.webdriver.common.action_chains import ActionChains

driver=self.webdriver
user = self.find_element_by_id("selUsers")
for option in user.find_elements_by_tag_name("option"):
   if option.text == "Admin, Ascender":
      actionChains = ActionChains(driver)
      actionChains.double_click(option).perform()
试试这个:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains

usernameStr = 'xxxxxx'
passwordStr = 'xxxxx'

browser = webdriver.Chrome()
browser.get(('https://accounts.google.com/ServiceLogin?'
         'service=mail&continue=https://mail.google'
         '.com/mail/#identifier'))


username = browser.find_element_by_id('identifierId')
username.send_keys(usernameStr)
nextButton = browser.find_element_by_id('identifierNext')

nextButton.click()

# wait for transition then continue to fill items
password = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH,'//*    [@id="password"]/div[1]/div/div[1]/input')))

password.send_keys(passwordStr)

signInButton = browser.find_element_by_id('passwordNext')
signInButton.click()

apsButton = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH,'//[@id="gbwa"]/div/a')))

apsButton.click()
driveButton = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH,'//*[@id="gb49"]/span[1]')))
driveButton.click()