1 #coding=utf-8 2 from selenium import webdriver 3 #from selenium.common.exceptions import NosuchElementException 4 import unittest,os,time 5 6 source=open("F:\\script\\py_scripts\\login_parameter\\username.txt","r")#用户名文件 7 un = source.read()#读取用户名 8 source.close() 9 10 source2=open("F:\\script\\py_scripts\\login_parameter\\password.txt","r")#用户名文件 11 pw = source2.read()#读取用户名 12 source2.close() 13 14 def login(): 15 #driver=self.driver 16 #driver.maximize_window() 17 driver.find_element_by_id("username").clear() 18 driver.find_element_by_id("username").send_keys(un) 19 print(un) 20 driver.find_element_by_id("password").clear() 21 driver.find_element_by_id("password").send_keys(pw) 22 print(pw) 23 driver.find_element_by_id("loginbtn").click() 24 time.sleep(3) 25 26 driver=webdriver.Chrome() 27 driver.get("http://cloud.pingnanlearning.com/test/login/index.php") 28 login()
时间: 2024-10-10 14:48:17