web自动化之 登录 -投标
Posted 测试媛S
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了web自动化之 登录 -投标相关的知识,希望对你有一定的参考价值。
from selenium import webdriver
import unittest
from ddt import ddt, data
from datas import login_data
from datas import bid_data
from common.read_config import ReadConfig
from common.log import Log
from pages.login_page import LoginPage
from pages.index_page import IndexPage
from pages.bid_page import BidPage
@ddt
class TestBid(unittest.TestCase):
"""投标"""
config = ReadConfig()
log = Log()
@classmethod
def setUpClass(cls):
cls.driver = webdriver.Chrome()
url = cls.config.get_value(‘environment‘, ‘url‘)
cls.driver.get(url)
cls.driver.maximize_window()
cls.login_page = LoginPage(cls.driver)
cls.index_page = IndexPage(cls.driver)
cls.bid_page = BidPage(cls.driver)
cls.login_page.send_phone_value(login_data.correct[‘phone‘])
cls.login_page.send_password_value(login_data.correct[‘password‘])
cls.login_page.click_submit_element()
cls.index_page.click_bid()
def setUp(self):
pass
def test_bid_success(self):
self.bid_page.send_money(bid_data.correct[‘money‘])
self.bid_page.click_submit_bid()
try:
self.assertTrue(bid_data.correct[‘expected‘] == self.bid_page.get_assert_info_success().text)
except AssertionError as e:
self.log.log_error(‘断言失败,报错原因:{}‘.format(e))
self.bid_page.click_close_success_pop()
self.bid_page.clear_input_money()
@data(*bid_data.pop_error)
def test_bid_error_pop(self, data):
self.bid_page.send_money(data[‘money‘])
self.bid_page.click_submit_bid()
try:
self.assertTrue(data[‘expected‘] == self.bid_page.get_assert_info_error_pop().text)
except AssertionError as e:
self.log.log_error(‘断言失败,报错原因:{}‘.format(e))
self.bid_page.click_error_pop()
self.bid_page.clear_input_money()
def test_bid_error_window(self):
self.bid_page.send_money(bid_data.window_error[‘money‘])
try:
self.assertTrue(bid_data.window_error[‘expected‘] == self.bid_page.get_assert_info_error_window().text)
except AssertionError as e:
self.log.log_error(‘断言失败,报错原因:{}‘.format(e))
self.bid_page.clear_input_money()
def tearDown(self):
pass
@classmethod
def tearDownClass(cls):
cls.driver.quit()
if __name__==‘__main__‘:
unittest.main()
以上是关于web自动化之 登录 -投标的主要内容,如果未能解决你的问题,请参考以下文章