__author__ = 'zhangliping' from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.action_chains import ActionChains #引入ActionChains鼠标操作类 from selenium import webdriver from selenium.webdriver.common.alert import Alert import time
browser = webdriver.Chrome('C:/TAP/autodependency/bin/chromedriver.exe') UserName = 'zhangliping' PassWord = 'windows13,' test_url = 'http://crm.XXX.com/' browser.get(test_url) browser.maximize_window()
browser.find_element_by_id('username').send_keys(UserName) browser.find_element_by_id('password').send_keys(PassWord)
browser.find_element_by_name('submit').click() time.sleep(3)
browser.get("http://crm.XXX.com/main.php?do=new\_crm\_treeview") Alert = browser._switch_to.alert Alert.accept() article = browser.find_element_by_link_text("业务系统登录平台") ActionChains(browser).move_to_element(article).perform()
browser.find_element_by_xpath('//*[@id="dd0"]/div[1]/a[2]').click() browser.find_element_by_xpath('//*[@id="dd1"]/div[10]/a[2]').click() browser.find_element_by_xpath('//*[@id="dd472"]/div[1]/a[2]').click() browser.find_element_by_xpath('//*[@id="sd475"]').click()