random csv----线性测试
#线性脚本 from selenium import webdriver import time import random import csv with open("data_csv.csv","r",encoding="utf-8")as f: data =csv.reader(f) for i in data : driver = webdriver.Chrome() driver.get("https://mail.163.com/register/index.htm?from=163mail&utm_source=163mail") #输入有效email: # 生成随机数 email = i[0]+str(random.randint(0,1)) driver.find_element_by_xpath('//*[@id="username"]').send_keys(email) #输入有效的密码 password = i[1]+str(random.randint(0,9999)) driver.find_element_by_xpath("//*[@id='password']").send_keys(password) #输入有效手机号 driver.find_element_by_xpath('//*[@id="phone"]').send_keys(i[2]) #点击同意 driver.find_element_by_xpath('/html/body/div[2]/div/div/div[2]/div[2]/div[4]/span').click() #点击注册 driver.find_element_by_xpath('/html/body/div[2]/div/div/div[2]/div[2]/div[5]/a[1]').click() #设置断言 one = "https://mail.163.com/" two =driver.current_url #if判断一下是否正确 if one == two: print("注册成功") else: print("注册不成功")