Selenium_model开发
1. 登录页面
2. 访问问题
selenium 数据驱动:
@pytest.mark.parametrize('case',InvestData.error_popup_data)
def test_invest_error_window(self, case,invest_fixture):
"""投资失败,弹框上出现提示信息的用例"""
# 用例:投资金额为0
invest_page = invest_fixture[0]
# 刷新投资页面
invest_page.page_refresh()
# 输入投资金额 ,
invest_page.input_invest_money(case['money'])
#expected = '请正确填写投标金额'
# 点击投资
invest_page.click_invest()
# 获取页面弹框的提示
res = invest_page.get_window_error_info()
invest_page.click_close_error_popup()
try:
assert case['expected'] == res
except AssertionError as e:
log.error("用例--{}---执行未通过".format(case['title']))
log.exception(e)
time.sleep(10)
raise e
else:
log.info("用例--{}---执行通过".format(case['title']))
@pytest.mark.parametrize('case', InvestData.success_data)
def test_success(self, case, invest_fixture):
"""投资成功的用例"""
# 用例:投资金额为200
invest_page,user_page = invest_fixture
# 获取用户的余额(投资前)
start_amount = invest_page.get_user_amount()
# 输入投资金额
invest_page.input_invest_money(case['money'])
# 点击投资
invest_page.click_invest()
# 获取页面弹框的提示成功的信息
res = invest_page.get_invest_info()
# 点击查看投资成功的信息,跳转到用户页面
invest_page.click_invest_success()
# 获取用户页面的用户余额(投资后)
end_amount = user_page.get_user_amount()
try:
assert case['expected'] == res
assert Decimal(start_amount) - Decimal(end_amount) == Decimal(case(['money']))
except AssertionError as e:
log.error("用例--{}---执行通过".format(case['title']))
log.exception(e)
time.sleep(10)
raise e
else:
log.info("用例--{}---执行通过".format(case['title']))