# encoding=utf-8 import time import sys import testlogin.login as login reload(sys) sys.setdefaultencoding('utf8') def selectMenu(argument): dr = login.driver '''選擇top導航菜單''' # li_0000 = 與我有關,li_0001 = 項目管理,li_0002 = 評審管理,li_0003 = 客戶管理,li_0005 = 系統管理 menulist = {"li_0000", "li_0001", "li_0002", "li_0003", "li_0005"} for i in menulist: if i == argument: dr.find_element_by_id("my_menu") dr.find_element_by_id(i).click() return "pass" def selectLeftMenu(argument): dr = login.driver '''選擇left導航菜單''' # c_00010101(商機錄入),c_00010102(商機查詢),c_00010104(商機跟蹤),c_00010107(商機補錄),c_00010108(商機狀態變動) leftmenulist = {"c_00010101", "c_00010102", "c_00010104", "c_00010107", "c_00010108"} for i in leftmenulist: if i == argument: '''若是傳入的argument=導航菜單的ID了,我就進行點擊事件''' time.sleep(1) dr.find_element_by_id("my_menu") dr.find_element_by_id("li_0001").click() time.sleep(1) dr.find_element_by_id("CM_mMeun_div") dr.find_element_by_xpath(".//*[@id='a_0001']/div[1]/span").click() time.sleep(1) dr.find_element_by_id(i).click() time.sleep(1) dr.switch_to_frame("mainConFrame") return "pass" def selecrCss(id, name): dr = login.driver if id != '': js = "var id = document.getElementById(%d);''id.style.border=\"2px solid red\";" % id dr.execute_script(js) if name != '': js = "var id = document.getElementByName(%d);''id.style.border=\"2px solid red\";" % name dr.execute_script(js) '''退出瀏覽器驅動''' def quit(): dr = login.driver dr.quit()