from selenium import webdriver
import time
import random
global userName,userPassword #为了便于使用,定义为全局变量
userName = ''
userPassword = ''
driver = webdriver.Chrome()
driver.maximize_window()
driver .get("http://192.168.23.102:8080/sxcass/index.jsp")
print("Before login.........")
#打印当前页面title
title=driver.title
print(title)
#打印当前页面URL
now_url =driver.current_url
print(now_url)
#随机获取用户名和密码
def get_userNameAndPassword():
global userName, userPassword
usableName_char = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" # 可作为用户名的字符!@#$%^&*()_+=-><:}{?/
usablePassword_char = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_.1234567890" # 可作为密码的字符,根据所需可适当增减
e_userName = [] # 定义一个临时List变量,使用list.append添加字符
e_userPassword = []
for i in range(8):
e_userName.append(random.choice(usableName_c
python+selenium随机添加用户自动化测试脚本
最新推荐文章于 2024-01-19 10:43:49 发布