#案例:演示鼠标api!
#演示:鼠标单击
#演示:鼠标双击
#演示:鼠标拖拽
#演示:鼠标悬停!
from selenium import webdriver # 导入webdriver包
import time
from selenium.webdriver.common.action_chains import ActionChains
driver=webdriver.Chrome()
driver.maximize_window() # 最大化浏览器
driver.implicitly_wait(30)
# driver.get("http://oss.52studyit.net/webzdh/drop.html") # 通过get()方法,打开一个url站点
driver.get("https://www.baidu.com/")
#演示:鼠标单击
#ActionChains(driver).click(ele).perform()
# ele_reg=driver.find_element_by_css_selector("button[title='加入会员']")
# ActionChains(driver).click(ele_reg).perform()
#演示:鼠标双击
# ActionChains(driver).double_click(ele).perform()
# ele_user=driver.find_element_by_id("user")
# ele_user.send_keys("abcd")
# time.sleep(2)
# ActionChains(driver).double_click(ele_user).perform()
#演示:鼠标拖拽
# time.sleep(2)
# ele_div1=driver.find_element_by_id("div1")
# ele_div2=driver.find_element_by_id("div2")
# ActionChains(driver).drag_and_drop(ele_div1,ele_div2).perform();
# ele_div1=driver.find_element_by_id("div1")
# ActionChains(driver).drag_and_drop_by_offset(ele_div1,500,300).perform()
#演示:鼠标悬停在某元素上!
#ActionChains(driver).move_to_element(ele).perform()
ele_setting=driver.find_element_by_css_selector("#s-usersetting-top")
ActionChains(driver).move_to_element(ele_setting).perform()
time.sleep(2)
ele_searchSet=driver.find_element_by_css_selector("#s-user-setting-menu > div > a.setpref.first > span")
ele_searchSet.click()
time.sleep(5)
driver.quit() # 关闭并退出浏览器