一、通过txt文件引入用户名密码
1 #coding=utf-8
from selenium import webdriver
#from selenium.common.exceptions import NosuchElementException
import unittest,os,time source=open("F:\\script\\py_scripts\\login_parameter\\username.txt","r")#用户名文件
un = source.read()#读取用户名
source.close() source2=open("F:\\script\\py_scripts\\login_parameter\\password.txt","r")#用户名文件
pw = source2.read()#读取用户名
source2.close() def login():
#driver=self.driver
#driver.maximize_window()
driver.find_element_by_id("username").clear()
driver.find_element_by_id("username").send_keys(un)
print(un)
driver.find_element_by_id("password").clear()
driver.find_element_by_id("password").send_keys(pw)
print(pw)
driver.find_element_by_id("loginbtn").click()
time.sleep(3) driver=webdriver.Chrome()
driver.get("http://cloud.pingnanlearning.com/test/login/index.php")
login()

二、通过字典引入用户名密码 
login_parameter.py
1 #coding=utf-8
from selenium import webdriver
#from selenium.common.exceptions import NosuchElementException
import unittest,os,time
import userinfo
'''
source=open("F:\\script\\py_scripts\\login_parameter\\username.txt","r")#用户名文件
un = source.read()#读取用户名
source.close() source2=open("F:\\script\\py_scripts\\login_parameter\\password.txt","r")#用户名文件
pw = source2.read()#读取用户名
source2.close()
'''
def login(un,pw):
driver.find_element_by_id("username").clear()
driver.find_element_by_id("username").send_keys(un)
print(un)
driver.find_element_by_id("password").clear()
driver.find_element_by_id("password").send_keys(pw)
print(pw)
driver.find_element_by_id("loginbtn").click()
time.sleep(3) info=userinfo.zidian()
for un,pw in info.items():
driver=webdriver.Chrome()
driver.get("http://cloud.pingnanlearning.com/test/login/index.php")
login(un,pw)
 #userinfo.py
def zidian():
data={'candy':'','candy1':''}
print("success reader username and password!")
return data

【Python练习】文件引用用户名密码登录系统的更多相关文章

  1. Python用户名密码登录系统(MD5加密并存入文件,三次输入错误将被锁定)及对字符串进行凯撒密码加解密操作

    # -*- coding: gb2312 -*- #用户名密码登录系统(MD5加密并存入文件)及对字符串进行凯撒密码加解密操作 #作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.co ...

  2. pyhton学习,day1作业,用户名密码登录模块

    要求,通过用户名密码登录,登录错误3次,锁定用户名 # coding=utf-8 # Author: RyAn Bi import os, sys #调用系统自己的库 accounts_file = ...

  3. cassandra根据用户名密码登录cqlsh

     修改conf目录下cassandra.yaml文件 authenticator: PasswordAuthenticator //将authenticator修改为PasswordAuthentic ...

  4. 用户名密码登录小程序及input与raw_input区别。

    一.此次程序需要实现: 1.设定固定的用户名密码 2.用户名密码输入正确打印登录正确信息 3.仅仅运行三次登录 二.本次使用的python版本为: Windows下版本号: C:\Users\dais ...

  5. Python之简单的用户名密码验证

    题目要求: 输入用户名密码 认证成功后显示欢迎信息 输错三次后锁定   #要求使用文件存储用户名和密码,每次从文件读入用户名和密码用来验证,如果输错三次密码该账户会被锁定,并讲锁定的用户名写入文件 # ...

  6. Spring Security之用户名+密码登录

    自定义用户认证逻辑 处理用户信息获取逻辑 实现UserDetailsService接口 @Service public class MyUserDetailsService implements Us ...

  7. SpringSecurity实现用户名密码登录(Token)

    传统的应用是将Session放在应用服务器上,而将生成的JSESSIONID放在用户浏览器的Cookie中,而这种模式在前后端分离中就会出现以下问题 1,开发繁琐. 2,安全性和客户体验差 3,有些前 ...

  8. 【转】IIS网站浏览时提示需要用户名密码登录-解决方法

    打开iis,站点右键----属性----目录安全性----编辑----允许匿名访问钩选 IIS连接127.0.0.1要输入用户名密码的解决办法原因很多,请尝试以下操作: 1.查看网站属性——文档看看启 ...

  9. MongoDB 用户名密码登录

    Mongodb enable authentication MongoDB 默认直接连接,无须身份验证,如果当前机器可以公网访问,且不注意Mongodb 端口(默认 27017)的开放状态,那么Mon ...

随机推荐

  1. 【重要】攻击动作时间段判断~使用动画time比较动画length和使用一个变量数组做延迟

    using UnityEngine; using System.Linq; using System.Collections.Generic; [RequireComponent(typeof(Cha ...

  2. iOS 在已有项目添加CoreData

    本文转载至 http://cnbin.github.io/blog/2016/03/11/ios-zai-yi-you-xiang-mu-tian-jia-coredata/ 如果是新项目很好说,新建 ...

  3. codeforces水题100道 第十七题 Codeforces Beta Round #25 (Div. 2 Only) A. IQ test (brute force)

    题目链接:http://www.codeforces.com/problemset/problem/25/A题意:在n个书中找到唯一一个奇偶性和其他n-1个数不同的数.C++代码: #include ...

  4. thrift安装及使用

    下载Thrift:http://thrift.apache.org/download ■ 将thrift-0.11.0.exe重命名为thrift.exe: ■ 解压thrift-0.11.0.tar ...

  5. 119、 android:hardwareAccelerated="true"or"false"硬件加速的重要性

    每次做项目都会遇见一些特别简单的问题,但是又很费时间来让你解决的问题. 1.本身想实现一个简单的画廊效果,可是每次图片的显示都不能显示在正中的位置,真的很烦人,也花费了很长时间.最终还是知道了原因.解 ...

  6. struts1的配置文件详解11111

    要想使用Struts,至少要依靠两个配置文件:web.xml和struts-config.xml.其中web.xml用来安装Struts框架.而struts-config.xml用来配置在Struts ...

  7. 【python3】爬取新浪的栏目分类

    目标地址: http://www.sina.com.cn/ 查看源代码,分析: 1 整个分类 在 div main-nav 里边包含 2 分组情况:1,4一组 . 2,3一组 . 5 一组 .6一组 ...

  8. 二叉树的实现(Java语言描述)

    实现二叉树   并先序遍历之. package 二叉树的实现; public class BinaryTree<T> { class Node { int value; // 该节点存储的 ...

  9. css3整理--box-shadow

    box-shadow语法:(想法:用阴影来做边框,就不会出现动态改变边框宽度而产生的重排问题) 对象选择器{box-shadow:投影方式 X轴偏移量 Y轴偏移量 阴影模糊半径 阴影扩展半径 阴影颜色 ...

  10. 二手回收能否翻过BAT这座大山?

    自2015年几大合并事件后,互联网江山基本都归于BAT三家.即便近日战火熊熊的本地生活和外卖也都是百度.阿里和腾讯的家门事.创业浪潮在2015年疯狂过后,留给下一年的风口似乎不多了. 不过有媒体预测智 ...