import time
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome()
driver.get('http://www.baidu.com')
driver.maximize_window()
driver.implicitly_wait(10)
el = driver.find_element_by_name('wd')
# context_click()
# :右击
time.sleep(2)
# 动作链条 链条头+动作+执行
ActionChains(driver).context_click(el).perform()
# double_click()
# :双击
time.sleep(2)
el.click()
driver.find_element_by_name('wd').send_keys('python测试')
el2 = driver.find_element_by_id('su') # 百度一下
ActionChains(driver).double_click(el2).perform() # perform:运转
# drag_and_drop() :拖动
# move_to_element() :鼠标移动到一个元素上
time.sleep(2)
el3 = driver.find_element_by_name('tj_settingicon') # 设置
ActionChains(driver).move_to_element(el3).perform()
time.sleep(1)
driver.find_element_by_link_text('高级搜索').click()
# click_and_hold() :按下鼠标左键在一个元素上
time.sleep(3)
driver.close()