Ejemplo n.º 1
0
class TestCase(unittest.TestCase):
    def setUp(self) -> None:

        self.driver = browser_type("chr")
        self.driver.implicitly_wait(10)
        self.lp = LoginPage(self.driver, LoginPage.url)
        self.ip = UserCenterPage(self.driver, UserCenterPage.url)
        self.sp = SearchPage(self.driver, SearchPage.url)
        self.add = AddCart(self.driver, AddCart.url)
        self.shop = Shop(self.driver, Shop.url)
        self.r = Register(self.driver, Register.url)

    def tearDown(self) -> None:
        self.driver.quit()

    @classmethod
    def setUpClass(cls) -> None:
        pass

    @classmethod
    def tearDownClass(cls) -> None:
        # 发送邮件
        Logger().log().info("--------------测试完成--------------")

    #登录
    @file_data("../config/login.yaml")
    def test_01_login(self, **kwargs):
        self.lp.login(kwargs["username"], kwargs["password"])
        self.assertTrue(
            self.lp.assert_text(kwargs["validata"]["type"],
                                kwargs["validata"]["value"],
                                kwargs["validata"]["expect"]))

    #注册
    @file_data("../config/register.yaml")
    def test_04_register(self, **kwargs):
        self.r.register(kwargs["username"], kwargs["password"])
        self.assertTrue(
            self.r.assert_text(kwargs["validata"]["type"],
                               kwargs["validata"]["value"],
                               kwargs["validata"]["expect"]))

    #搜索
    @file_data("../config/search.yaml")
    def test_02_search(self, **kwargs):
        self.sp.search_shop(kwargs["search_content"])
        #self.assertTrue(self.sp.assert_text(kwargs["validata"]["type"], kwargs["validata"]["value"], kwargs["validata"]["expect"]))

    #个人中心
    @file_data("../config/user_center.yaml")
    def test_03_user_center(self, **kwargs):
        #正常登录
        self.lp.login("666666", "111111")
        #搜索订单号
        self.ip.search_infor(kwargs['search_content'])

    #加入购物车
    def test_03_add_shop_cart(self):
        #正常登录
        self.lp.login("666666", "111111")
        #选择商品
        self.shop.click_shop()
        #切换句柄
        headle = self.driver.window_handles
        self.driver.close()
        self.driver.switch_to.window(headle[2])
        #选择规格加入购物车
        self.add.add_shop_cart()
Ejemplo n.º 2
0
 def test_login(self, data, browser):
     lg = LoginPage(browser)
     lg.login(data['user'], data['pwd'])
     print('这是一个登录的')
Ejemplo n.º 3
0
 def test_login(self, data, browser):
     lg = LoginPage(browser)
     lg.login(data['user'], data['pwd'])
     text = lg.assert_text()
     assert text == data['text']