Exemplo n.º 1
0
 def test_goods_comment(self):
     """商品评论"""
     allure.attach("点击我的", "进入个人中心")
     # 进入我的
     PersonalPage(self.driver).personal_click()
     time.sleep(1)
     # 选择待评价
     PersonalPage(self.driver).comment_click()
     # 选择待评价的订单
     allure.attach("进入待评价", "选择待评价订单")
     OrderShowPage(self.driver).order_click()
     # 输入评价
     text = "陌上花开,缓缓归矣!"
     CommentPage(self.driver).inpute_content(text)
     time.sleep(2)
     # 选择星星等级
     CommentPage(self.driver).click_start()
     # 点击提交
     CommentPage(self.driver).submitc_click()
     time.sleep(1)
     allure.attach("评论成功", "获取toast")
     # 获取toast文本
     toast = self.driver.find_element_by_xpath("//*[contains(@text,'成功')]")
     text = toast.text
     # 断言
     if text == "评论成功":
         assert 1
     else:
         Base(self.driver).screenshot("../screenshot/comment.png")
         assert 0
Exemplo n.º 2
0
 def test_buy_goods(self):
     allure.attach("点击我的", "进入个人中心")
     # 进入我的
     PersonalPage(self.driver).personal_click()
     # 获取金额
     money_b = float(PersonalPage(self.driver).get_value())
     allure.attach("购买商品前的金额:", f'{money_b}')
     allure.attach("点击首页", "进入商品促销")
     # 点击首页
     HomePage(self.driver).homepage_click()
     time.sleep(5)
     # 选择商品
     allure.attach("选择商品", "进入商品详情")
     HomePage(self.driver).goods_click()
     time.sleep(5)
     allure.attach("进入商品", "加入购物车")
     # 添加购物车
     CarPage(self.driver).addcar_click()
     # 确定
     CarPage(self.driver).click_ensure()
     allure.attach("选择商品", "进入购物车")
     # 点击购物车
     CarPage(self.driver).gocar_click()
     # 点击立即购买
     allure.attach("购物车", "立即购买")
     BuySalesPage(self.driver).buy_click()
     time.sleep(5)
     # 点击使用余额
     allure.attach("支付界面", "使用余额支付")
     CheckOrderPage(self.driver).balance_click()
     time.sleep(2)
     # 获取订单金额
     price = float(CheckOrderPage(self.driver).get_goods_price().strip("¥"))
     allure.attach("购买商品的金额:", f'{price}')
     # 点击提交订单
     CheckOrderPage(self.driver).submit_click()
     time.sleep(2)
     # 输入支付密码
     text = "123456"
     CheckOrderPage(self.driver).check_pwd_input(text)
     # 点击确定
     CheckOrderPage(self.driver).sure_click()
     time.sleep(2)
     # 点击返回上一页
     self.driver.back()
     # 进入个人中心
     PersonalPage(self.driver).personal_click()
     # 获取金额
     money_f = float(PersonalPage(self.driver).get_value())
     allure.attach("购买商品后的金额:", f'{money_f}')
     # 断言
     if money_b - price == money_f:
         assert 1
     else:
         Base(self.driver).screenshot("../screenshot/buy_sales.png")
         assert 0
Exemplo n.º 3
0
 def search_member(self, username):
     self.find_sendkeys("//*[@text='搜索']", username)
     print("-----debug", "//*[@text='{}']".format(username))
     sleep(3)
     ele = self.driver.find_elements(MobileBy.XPATH,
                                     "//*[@text='{}']".format(username))
     print("元素个数", ele)
     if len(ele) > 1:
         ele[1].click()
     return PersonalPage(self.driver)
Exemplo n.º 4
0
def personal_setup():
    driver = create_dirver()
    driver.maximize_window()
    driver.implicitly_wait(15)
    driver.get(conf.get('env', 'base_url') + conf.get("env", "url_path"))
    login_page = LoginPage(driver)
    # 登录
    login_page.login(conf.get("test_data", "phone"),
                     conf.get("test_data", "pwd"))
    # 创建首页对象
    index_page = IndexPage(driver)
    # 进入班级
    index_page.take_course()
    time.sleep(3)
    # 创建班级作业对象
    homework_page = HomeworkPage(driver)
    # 进入私信
    homework_page.take_personal()
    # 创建私信对象
    personal_page = PersonalPage(driver)
    yield homework_page, personal_page
    driver.quit()
Exemplo n.º 5
0
 def test_buy_sales(self):
     allure.attach("点击我的", "进入个人中心")
     PersonalPage(self.driver).personal_click()
     # 获取金额
     money_b = float(PersonalPage(self.driver).get_value())
     allure.attach("购买商品前的金额:", f'{money_b}')
     allure.attach("点击首页", "进入商品促销")
     # 进入首页
     HomePage(self.driver).homepage_click()
     time.sleep(2)
     # 点击促销商品
     HomePage(self.driver).sales_click()
     time.sleep(5)
     allure.attach("任意选择一商品", "进入商品详情")
     # 选择促销商品
     SalesPage(self.driver).sales_goods_click()
     time.sleep(5)
     allure.attach("商品详情", "立即购买")
     # 点击立即购买
     BuySalesPage(self.driver).buy_click()
     time.sleep(5)
     # 点击确认
     BuySalesPage(self.driver).ensure_click()
     allure.attach("支付界面", "使用余额支付")
     # 点击使用余额
     CheckOrderPage(self.driver).balance_click()
     time.sleep(3)
     # 获取订单金额
     price = float(CheckOrderPage(self.driver).get_goods_price().strip("¥"))
     allure.attach("购买商品的金额:", f'{price}')
     try:
         # self.driver.find_element_by_xpath("//*[contains(@text,'每人限购')]"):
         toast = self.driver.find_element_by_xpath(
             "//*[contains(@text,'每人限购')]")
         print(toast.text)
     except:
         # 点击提交订单
         CheckOrderPage(self.driver).submit_click()
         time.sleep(3)
         allure.attach("提交订单", "输入支付密码")
         # 输入支付密码
         text = "123456"
         CheckOrderPage(self.driver).check_pwd_input(text)
         # 点击确定
         CheckOrderPage(self.driver).sure_click()
         # 点击返回上一页
         for i in range(4):
             self.driver.back()
             time.sleep(2)
         allure.attach("点击我的", "进入个人中心")
         # 进入个人中心
         PersonalPage(self.driver).personal_click()
         # 获取金额
         money_f = float(PersonalPage(self.driver).get_value())
         allure.attach("购买商品后的金额:", f'{money_f}')
         # 断言
         if money_b - price == money_f:
             assert 1
         else:
             Base(self.driver).screenshot("../screenshot/buy_sales.png")
             assert 0
Exemplo n.º 6
0
 def get_personal_page(self):
     return PersonalPage(self.driver)
Exemplo n.º 7
0
 def personal(self):
     return PersonalPage(self.driver)
Exemplo n.º 8
0
"""
晒单评价
"""
from common.base import Base, preposition_code
from page.personal_page import PersonalPage


class OrderShowPage(Base):
    """元素定位"""
    order_loc = ("xpath", "//*[@text = '评价晒单']")  # 待评价订单
    """元素操作"""
    def order_click(self):
        """点击晒单评价"""
        orders = self.find_elements(self.order_loc)
        orders[0].click()


if __name__ == '__main__':
    driver = preposition_code()
    # 进入我的
    PersonalPage(driver).personal_click()
    # 点击待评价
    PersonalPage(driver).comment_click()
    # 选择待评价的订单
    OrderShowPage(driver).order_click()