# encoding=utf-8from selenium import webdriver # 导入web驱动import time # 导入时间# import testCommon.home as commandriver = webdriver.Chrome()def openWebLogin(flag): """ :param flag:0代表创建人,1代表审批人 :return: """ # driver = webdriver.Chrome() driver.get("http://xxxxxxxxxxxxx.com") driver.maximize_window() # 窗口最大化 time.sleep(1) driver.find_element_by_id('loginForm') driver.find_element_by_id('userName').clear() js1 = "var username=document.getElementById(\"userName\");username.style.border=\"2px solid red\";" driver.execute_script(js1) time.sleep(1) if flag == 0: driver.find_element_by_id('userName').send_keys('0260000006') time.sleep(1) driver.find_element_by_id('pwd').clear() js2 = "var pwd = document.getElementById(\"pwd\");pwd.style.border=\"2px solid red\";" driver.execute_script(js2) time.sleep(1) driver.find_element_by_id('pwd').send_keys('1') time.sleep(2) # driver.execute_script('alert("输入框红了。")') driver.find_element_by_id('loginForm').submit() if flag == 2: driver.find_element_by_id('userName').send_keys('0096000020') time.sleep(1) driver.find_element_by_id('pwd').clear() js2 = "var pwd = document.getElementById(\"pwd\");pwd.style.border=\"2px solid red\";" driver.execute_script(js2) time.sleep(1) driver.find_element_by_id('pwd').send_keys('1') time.sleep(2) # driver.execute_script('alert("输入框红了。")') driver.find_element_by_id('loginForm').submit() driver.implicitly_wait(5) return driverif __name__ == '__main__': openWebLogin()