码迷,mamicode.com
首页 > 编程语言 > 详细

【Python练习】文件引用用户名密码登录系统

时间:2017-08-31 22:18:36      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:cep   http   index   col   learn   close   分享   from   chrome   

 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()

技术分享

技术分享技术分享

 

【Python练习】文件引用用户名密码登录系统

标签:cep   http   index   col   learn   close   分享   from   chrome   

原文地址:http://www.cnblogs.com/zhuzhubaoya/p/7460655.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!