Example #1
0
 def test_event_good(self):
     """测试活动商品的用例"""
     driver = open_mobile()
     eventgoods = GoodsPage(driver)  # 实例化活动商品的类
     eventgoods.click_my()  # 点击
     eventgoods.click_login_register()  # 点击登录和注册
     eventgoods.input_username("18000180007")
     eventgoods.input_password("123456")
     eventgoods.click_login()  # 点击立即登录
     allure.attach("登录成功", "进入个人中心")
     time.sleep(3)
     pre_balance = eventgoods.show_my_balance()  # 显示我的余额
     allure.attach("获取购物前的余额", f"购物前的账户余额:{pre_balance}")
     eventgoods.back_home()  # 回到主页
     allure.attach("点击首页", "跳转到首页")
     eventgoods.click_commodity_promotion()  # 选择促销商品
     eventgoods.click_good()  # 选择一件商品
     eventgoods.immediately_buy()  # 点击立即购买
     eventgoods.confirm()  # 点击确认提交
     allure.attach("购买一件商品", "选择")
     eventgoods.balance_pay()  # 点击余额支付
     allure.attach("使用余额支付", "购买商品")
     price = eventgoods.good_price()  # 点击获取商品的价格
     allure.attach("购买商品后的价格", f"获取商品的价格:{price}")
     eventgoods.submit_order()  # 点击立即提交
     eventgoods.input_pay_pwd("123456")  # 输入支付密码
     eventgoods.pay_sure()  # 确定密码
     allure.attach("确定支付", "支付成功")
     for i in range(4):
         eventgoods.back()  # 返回上级
     eventgoods.click_my()  # 点击我的
     back_balance = eventgoods.show_my_balance()  # 获取结算后的余额
     allure.attach("获取结算后的余额", f"获取结算后的余额:{back_balance}")
     assert back_balance == (pre_balance - price)  # 判断结算后的月是否等于结算前减去商品价格
     eventgoods.close_mobile()
Example #2
0
 def test_comment(self):
     """测试评论"""
     driver = open_mobile()
     com = CommentPage(driver)  # 实例化评论的方法
     com.click_my()  # 点击我的
     com.click_login_register()  # 点击登录
     com.input_username("18000180007")  # 输入账号密码
     com.input_password("123456")  # 输入密码
     com.click_login()  # 点击登录
     allure.attach("点击我的", "进入个人中心")
     com.wait_comment()  # 点击等待评价
     T = com.pre_comment_text()  # 获取等待评价前的文本信息
     print(T)
     allure.attach("评价前的商品文本信息", f"{T}")
     time.sleep(3)
     com.order_show()  # 点击晒单评价
     allure.attach("评价商品", "五星好评")
     com.comment("你好")  # 输入文本内容
     com.play_start()  # 为服务打分
     com.submit()  # 点击提交
     time.sleep(5)  # 等待一段时间
     allure.attach("跳转点击已评价", "切换到已评价页面")
     com.already_comment()  # 点击已评价
     t = com.back_comment_text()  # 获取已评价的所有评价
     for i in t:  # 将所有的评价循环出来
         assert T == i.get_attribute("text")  # 判断之前取出来的值是否等于评价后的值
     allure.attach("断言商品", "当评价前的商品出现在已评价里面断言成功")
     com.close_mobile()
Example #3
0
 def test_normal_good(self):
     """测试正常商品的购买"""
     driver = open_mobile()
     normal = GoodsPage(driver)  # 实化类
     normal.click_my()  # 点击我的
     normal.click_login_register()  # 点击登录
     normal.input_username("18000180007")  # 输入账号密码
     normal.input_password("123456")
     normal.click_login()  # 点击登录
     allure.attach("登录成功", "进入个人中心")
     time.sleep(3)
     pre_balance = normal.show_my_balance()  # 结算前的余额
     print(pre_balance)
     allure.attach("获取前购物前余额", f"获取购买商品前的余额:{pre_balance}")
     normal.back_home()  # 返回首页
     allure.attach("选择商品", "选择正常商品")
     normal.up_slither()  # 上滑选择商品
     normal.rice()  # 选择商品
     normal.immediately_buy()  # 点击立即购买
     normal.confirm()  # 点击确定
     allure.attach("余额支付", "选择余额支付")
     normal.balance_pay()  # 点击余额支付
     price = normal.good_price()  # 获取商品价格
     allure.attach("获取结算后的商品价格", f"获取商品的价格{price}")
     print(price)
     normal.submit_order()  # 点击提交订单
     allure.attach("输入密码", "确定支付")
     normal.input_pay_pwd("123456")  # 输入支付密码
     normal.pay_sure()  # 点击确定
     for i in range(3):
         normal.back()  # 返回上级
     normal.click_my()  # 点击我的
     back_balance = normal.show_my_balance()  # 获取结算后的余额
     allure.attach("断言", f"获取结算后的余额:{back_balance}")
     assert back_balance == (pre_balance - price)  # 判断结算后的月是否等于结算前减去商品价格
     normal.close_mobile()
Example #4
0
def open_m():
    driver = open_mobile()  # 打开手机
    return driver
Example #5
0
    def my_again(self):
        """再次进入个人中心"""
        self.click(self.my_loc)

    def my_new_money(self):
        """获取我的余额"""
        self.click(self.my_money_loc)
        my_element = self.find_element(self.my_money_loc)
        my_money_2 = my_element.get_attribute("text")
        my_money = float(my_money_2)
        return my_money


if __name__ == '__main__':

    driver = open_mobile()
    buy = BuyGoods(driver)
    # 首页
    buy.home_page()
    #商品分类
    buy.goods_class()
    # 点击电脑分类
    buy.computer_class()
    # 点击笔记本分类
    buy.notebook()
    # #点击笔记本
    buy.select_notebook_goods()
    # 立即购买
    buy.buy_button()
    # 确定
    buy.confirm_button()
 def setUp(self):
     driver = open_mobile()
     self.sag = ShoppingActivityGoods(driver)
Example #7
0
 def setUp(self):
     """开启app"""
     driver = open_mobile()
     self.ev = Evaluate(driver)
 def setUp(self):
     driver = open_mobile()
     self.sg = ShoppingGoods(driver)