加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
买入基金理财用例.py 24.72 KB
一键复制 编辑 原始数据 按行查看 历史
唐敏香 提交于 2023-08-11 10:39 . web自动化第一次提交
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from unittest import TestCase
import pymysql
import time
host="localhost"
user="root"
password="root"
database="finance"
# 专门处理增,删,改
def update(sql,param):
con = pymysql.connect(host=host,user=user,password=password,database=database)
cursor = con.cursor()
cursor.execute(sql,param)
con.commit()
cursor.close()
con.close()
def select(sql,param):
con = pymysql.connect(host=host,user=user,password=password,database=database)
cursor = con.cursor()
cursor.execute(sql,param)
data = cursor.fetchall()
con.commit()
cursor.close()
con.close()
return data
# 增加lisi4 lisi5 lisi6 lisi7
sql1="INSERT INTO user (id,username,password,paypwd) VALUE (%s,%s,%s,%s)"
param1=['7','lisi4','123456','666666']
param2=['8','lisi5','123456','666666']
param3=['9','lisi6','123456','null']
param4=['10','lisi7','123456','666666']
update(sql1,param1)
update(sql1,param2)
update(sql1,param3)
update(sql1,param4)
# 为lisi4 lisi5 lisi6 lisi7增加银行卡
sql2="INSERT INTO bankcard (id,cardBank,type,cardNum,userId,balance,defaultl) VALUE (%s,%s,%s,%s,%s,%s,%s)"
# lisi4
param5=['10','中国建设银行','1','1231234564561231','7','10.00','1']
param6=['11','中国建设银行','1','4567894567894567','9','10000.00','1']
param7=['12','中国农业银行','1','2345678923456789','10','10000.00','1']
param8=['13','中国建设银行','1','2342342345675676','10','10000.00','0']
param9=['14','中国建设银行','1','1234567456789456','10','10000.00','0']
update(sql2,param5)
update(sql2,param6)
update(sql2,param7)
update(sql2,param8)
update(sql2,param9)
class TestFunds(TestCase):
def testfunds1(self):
sql = "update bankcard set balance = %s where cardNum = %s"
param = ['1000000', '1234567894521312']
update(sql, param)
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID,"username").send_keys("lisi")
wd.find_element(By.ID,"password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID,"login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT,"个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT,"零钱理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH,"//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH,'//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666666")
time.sleep(2)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(1)
# 银行卡余额
sql = "select balance from bankcard where cardNum=%s"
param = ['1234567894521312']
data = select(sql, param)
self.assertEqual((data[0][0]),999900)
wd.quit()
def testfunds2(self):
sql = "update bankcard set balance = %s where cardNum = %s"
param = ['1000000', '1234567894521312']
update(sql, param)
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID,"username").send_keys("lisi")
wd.find_element(By.ID,"password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID,"login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT,"个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT,"零钱理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH,"//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH,'//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666667")
time.sleep(2)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(1)
# 银行卡余额
sql = "select balance from bankcard where cardNum=%s"
param = ['1234567894521312']
data = select(sql, param)
self.assertEqual((data[0][0]),1000000)
wd.quit()
def testfunds3(self):
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID,"username").send_keys("lisi4")
wd.find_element(By.ID,"password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID,"login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT,"个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT,"零钱理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH,"//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH,'//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666666")
time.sleep(2)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(3)
# 银行卡余额
sql = "select balance from bankcard where cardNum=%s"
param = ['1231234564561231']
data = select(sql, param)
self.assertEqual((data[0][0]),10)
wd.quit()
def testfunds4(self):
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID,"username").send_keys("lisi5")
wd.find_element(By.ID,"password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID,"login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT,"个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT,"零钱理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH,"//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH,'//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666666")
time.sleep(2)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(2)
# 定位是否返回
result=wd.find_element(By.XPATH,"//div[@class='jconfirm-content-pane no-scroll']/div[@class='jconfirm-content']/div").text
print(result)
self.assertEqual(result,"买入失败!,请绑定银行卡")
wd.quit()
def testfunds5(self):
sql = "update bankcard set balance = %s where cardNum = %s"
param = ['1000000', '1234567894521312']
update(sql, param)
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID, "username").send_keys("lisi")
wd.find_element(By.ID, "password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID, "login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT, "个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT, "期限理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH, "//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH, '//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666666")
time.sleep(1)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(1)
# 银行卡余额
sql = "select balance from bankcard where cardNum=%s"
param = ['1234567894521312']
data = select(sql, param)
self.assertEqual((data[0][0]),995000)
wd.quit()
def testfunds6(self):
sql = "update bankcard set balance = %s where cardNum = %s"
param = ['1000000', '1234567894521312']
update(sql, param)
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID, "username").send_keys("lisi")
wd.find_element(By.ID, "password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID, "login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT, "个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT, "期限理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH, "//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH, '//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666667")
time.sleep(1)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(1)
# 银行卡余额
sql = "select balance from bankcard where cardNum=%s"
param = ['1234567894521312']
data = select(sql, param)
self.assertEqual((data[0][0]),1000000)
wd.quit()
def testfunds7(self):
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID, "username").send_keys("lisi4")
wd.find_element(By.ID, "password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID, "login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT, "个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT, "期限理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH, "//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH, '//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666666")
time.sleep(1)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(1)
result=wd.find_element(By.XPATH,"//div[@class='jconfirm-content-pane no-scroll']/div[@class='jconfirm-content']/div").text
print(result)
self.assertEqual(result,"买入失败!,银行卡余额不足")
wd.quit()
def testfunds8(self):
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID, "username").send_keys("lisi5")
wd.find_element(By.ID, "password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID, "login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT, "个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT, "期限理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH, "//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH, '//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666666")
time.sleep(1)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(1)
result=wd.find_element(By.XPATH,"//div[@class='jconfirm-content-pane no-scroll']/div[@class='jconfirm-content']/div").text
self.assertEqual(result,"买入失败!,请绑定银行卡")
wd.quit()
def testfund9(self):
sql = "update bankcard set balance = %s where cardNum = %s"
param = ['1000000', '1234567894521312']
update(sql, param)
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID, "username").send_keys("lisi")
wd.find_element(By.ID, "password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID, "login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT, "个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT, "基金理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH, "//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH, '//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666666")
time.sleep(1)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(1)
# 银行卡余额
sql = "select balance from bankcard where cardNum=%s"
param = ['1234567894521312']
data = select(sql, param)
self.assertEqual((data[0][0]),997000)
wd.quit()
def testfunds10(self):
sql = "update bankcard set balance = %s where cardNum = %s"
param = ['1000000', '1234567894521312']
update(sql, param)
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID, "username").send_keys("lisi")
wd.find_element(By.ID, "password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID, "login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT, "个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT, "基金理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH, "//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH, '//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666667")
time.sleep(1)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(1)
# 银行卡余额
sql = "select balance from bankcard where cardNum=%s"
param = ['1234567894521312']
data = select(sql, param)
self.assertEqual((data[0][0]),1000000)
wd.quit()
def testfunds11(self):
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID, "username").send_keys("lisi4")
wd.find_element(By.ID, "password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID, "login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT, "个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT, "基金理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH, "//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH, '//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666666")
time.sleep(1)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(1)
result=wd.find_element(By.XPATH,"//div[@class='jconfirm-content-pane no-scroll']/div[@class='jconfirm-content']/div").text
print(result)
self.assertEqual(result,"买入失败!,银行卡余额不足")
wd.quit()
def testfunds12(self):
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID, "username").send_keys("lisi5")
wd.find_element(By.ID, "password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID, "login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT, "个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT, "基金理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH, "//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH, '//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666666")
time.sleep(1)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(1)
result=wd.find_element(By.XPATH,"//div[@class='jconfirm-content-pane no-scroll']/div[@class='jconfirm-content']/div").text
self.assertEqual(result,"买入失败!,请绑定银行卡")
wd.quit()
def testfunds13(self):
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID, "username").send_keys("lisi6")
wd.find_element(By.ID, "password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID, "login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT, "个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT, "基金理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH, "//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH, '//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666666")
time.sleep(1)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(1)
result=wd.find_element(By.XPATH,"//div[@class='jconfirm-content-pane no-scroll']/div[@class='jconfirm-content']/div").text
self.assertEqual(result,"买入失败!,请前往个人信息设置支付密码")
wd.quit()
def testfunds14(self):
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID, "username").send_keys("lisi7")
wd.find_element(By.ID, "password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID, "login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT, "个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT, "基金理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH, "//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH, '//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666666")
time.sleep(1)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(1)
sql = "select balance from bankcard where userId=%s and defaultl = %s"
param = ['10',1]
data = select(sql, param)
self.assertEqual((data[0][0]),7000)
wd.quit()
def testfunds15(self):
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID, "username").send_keys("lisi7")
wd.find_element(By.ID, "password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID, "login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT,"个人中心").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT,"银行卡管理").click()
time.sleep(1)
# 点击设为默认
wd.find_element(By.XPATH,"//button[@class='btn default_btn' and @default-id='13']").click()
time.sleep(1)
# 点击个人理财
wd.find_element(By.LINK_TEXT, "个人理财").click()
time.sleep(1)
# 点击基金理财
wd.find_element(By.LINK_TEXT, "基金理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH, "//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH, '//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666666")
time.sleep(1)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(1)
sql = "select balance from bankcard where userId=%s and defaultl = %s"
param = ['10',1]
data = select(sql, param)
self.assertEqual((data[0][0]),7000)
wd.quit()
def testfunds16(self):
# 创建谷歌浏览器对象
wd = webdriver.Chrome()
# 打开网址
wd.get("http://localhost:90/")
# 窗口最大化
wd.maximize_window()
# 输入框
wd.find_element(By.ID, "username").send_keys("lisi5")
wd.find_element(By.ID, "password").send_keys("123456")
# 点击登陆按钮
wd.find_element(By.ID, "login_btn").click()
time.sleep(1)
# 点击个人中心
wd.find_element(By.LINK_TEXT, "个人理财").click()
time.sleep(1)
# 点击银行卡管理
wd.find_element(By.LINK_TEXT, "基金理财").click()
time.sleep(1)
# 点击投资
wd.find_element(By.XPATH, "//button[@class='btn btn-primary btn-sm buy_btn']").click()
time.sleep(2)
# 输入密码
wd.find_element(By.XPATH, '//div[@class="layui-layer-content"]/input[@id="password"]').send_keys("666666")
time.sleep(1)
# 点击确定
wd.find_element(By.XPATH,'//div[@class="layui-layer-btn layui-layer-btn-"]/a[@class="layui-layer-btn0"]').click()
time.sleep(1)
result=wd.find_element(By.XPATH,"//div[@class='jconfirm-content-pane no-scroll']/div[@class='jconfirm-content']/div").text
self.assertEqual(result,"买入失败!,请绑定银行卡")
wd.quit()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化