Ejemplo n.º 1
0
 def __init__(self, driver):
     self.home = HomePage(driver)
     self.user_center = UserCenter(driver)
     self.login = LoginPage(driver)
     self.address = AddressPage(driver)
     self.goods_detial = GoodsDetail(driver)
     self.confirm_order = ConfirmOrder(driver)
Ejemplo n.º 2
0
 def setup(self):
     # 创建一个字典,包装相应的启动参数
     desired_caps = dict()
     # 需要连接的手机的平台(不限制大小写)
     desired_caps['platformName'] = 'Android'
     # 需要连接的手机的版本号(比如 5.2.1 的版本可以填写 5.2.1 或 5.2 或 5 ,以此类推)
     desired_caps['platformVersion'] = '5.1'
     # 需要连接的手机的设备号(andoird平台下,可以随便写,但是不能不写)
     desired_caps['deviceName'] = '192.168.56.101:5555'
     # 需要启动的程序的包名
     desired_caps['appPackage'] = 'com.yunmall.lc'
     # 需要启动的程序的界面名
     desired_caps[
         'appActivity'] = 'com.yunmall.ymctoc.ui.activity.MainActivity'
     # 告诉appium不重置应用
     desired_caps['noReset'] = True
     # 支持中文
     desired_caps['unicodeKeyboard'] = True
     desired_caps['resetKeyboard'] = True
     # 连接appium服务器
     self.driver = webdriver.Remote('http://localhost:4723/wd/hub',
                                    desired_caps)
     self.home_page = HomePage(self.driver)
     self.my_page = MyPage(self.driver)
     self.address_page = AddressPage(self.driver)
     self.add_address_page = AddAddressPage(self.driver)
class TestCheckReceivingAddress(unittest.TestCase):
    def setUp(self) -> None:
        # 打开浏览器到添加收货地址界面
        # 创建对象
        driver = open_browser()
        self.login = AddressPage(driver)
        # 准备数据,进入到添加收货地址界面
        url = "http://172.16.1.224/ecshop/"
        self.login.open_url(url)
        self.login.login_address("grj123456", "grj123456")

    def tearDown(self) -> None:
        # 关闭浏览器
        self.login.close()

    @ddt.data(*test_data)
    def test_check_receiving_address(self, data):
        """测试用例,查询操作"""
        # 1.获取输入的id,然后根据id来进行定位要修改的地址
        b = self.login.a_number()
        a = data["id"] - 1
        if a < b:
            self.login.performance(a)
            self.login.driver.get_screenshot_as_file("./report/chrome.png")
        else:
            print("需要修改的地址编号不存在")
            return False
        # 断言,查看的姓名是否和原本的value值一样
        result = self.login.is_ckeck_success(data["consignee"])
        self.assertEqual(result, data["expect"])
Ejemplo n.º 4
0
 def test_buy_something(self):
     allure.attach('', '点击手机标签中的手机数码类目')
     self.category_page.click_cellphone_goods()
     allure.attach('', '选择荣耀畅玩6')
     self.goods_list_page = GoodsListPage(self.driver)
     self.goods_list_page.swipe_screen('up')
     self.goods_list_page.choose_goods()
     allure.attach('', '查看商品详情')
     self.goods_info_page = GoodsInfoPage(self.driver)
     self.goods_info_page.click_details_tab()
     allure.attach('', '查看评价')
     self.goods_info_page.click_comments_tab()
     allure.attach('', '返回商品购买页')
     self.goods_info_page.click_goods_tab()
     allure.attach('', '收藏商品')
     self.goods_info_page.click_collect_img()
     allure.attach('', '选择规格')
     self.goods_info_page.click_specification_button()
     allure.attach('', '选择全网通4G版')
     self.goods_info_page.click_version_4G_radio()
     allure.attach('', '数量加1')
     self.goods_info_page.click_plus_button()
     allure.attach('', '立即购买')
     self.goods_info_page.click_buy_now_button()
     allure.attach('', '选择收获地址')
     self.confirm_order_page = ConfirmOrderPage(self.driver)
     self.confirm_order_page.click_address_button()
     allure.attach('', '选择nero的地址')
     self.address_page = AddressPage(self.driver)
     self.address_page.click_address_of_nero_button()
     allure.attach('', '提交订单')
     self.confirm_order_page.click_submit_orders_button()
     res = self.category_page.is_toast_exist('支付方式', True, '立即支付页')
     assert res
 def setUp(self) -> None:
     # 打开浏览器到添加收货地址界面
     # 创建对象
     driver = open_browser()
     self.login = AddressPage(driver)
     # 准备数据,进入到添加收货地址界面
     url = "http://172.16.1.224/ecshop/"
     self.login.open_url(url)
     self.login.login_address("grj123456","grj123456")
Ejemplo n.º 6
0
 def setUp(self) -> None:
     # 打开浏览器到添加收货地址界面
     # 创建对象
     driver = open_browser()
     self.login = AddressPage(driver)
     # 准备数据,进入到添加收货地址界面
     url = "http://172.16.1.224/ecshop/"
     self.login.open_url(url)
     self.login.login_address("grj123456", "grj123456")
     # 得到最后一个数据的索引,就可以进行添加操作了
     self.a = self.login.a_number()
     self.login.performance(self.a)
Ejemplo n.º 7
0
class AddressHandle(BaseHandle):
    """ 地址操作类 """

    def __init__(self, driver):
        self.driver = driver
        self.addresspage = AddressPage()

    def get_address_count(self):
        element = self.driver.get_element(self.addresspage.get_address_count_css())
        return self.get_text_2_int(element)

    def to_add_address_frame(self):
        element = self.driver.get_element(self.addresspage.get_add_address_cls_name())
        self.click_element(element)
Ejemplo n.º 8
0
class TestMember:
    def setup(self):
        self.main = MainPage()
        self.address = AddressPage()

    @pytest.mark.skip
    @pytest.mark.parametrize('username, member_id, member_phone', get_data())
    def test_add(self, username, member_id, member_phone):
        self.address.goto_add_member().add_member(username, member_id,
                                                  member_phone)

    def test_search(self, search_data):
        a = self.address.search_member(search_data[0])
        print(search_data[0])
        assert a

    @pytest.mark.skip
    def test_del(self):
        assert self.address.delete_member_by_name('lucky_boy2')
Ejemplo n.º 9
0
 def test_MRYX_ST_usr_003(self):
     sleep(2)
     mp = MysPage(self.driver)
     mp.to_up(2000)
     sleep(2)
     mp.click_shipping_address()  # 点击收货地址
     mss = MysShippingAddressPage(self.driver)
     mss.click_new_add_shipping_address()  #点击新增地址
     mssn = MysShippingAddressNewAddShippingAddressPage(self.driver)
     sleep(2)
     mssn.send_receiver(self.receiver)  # 输入收货人名
     sleep(2)
     mssn.click_sex(self.sex)  # 点击性别
     sleep(2)
     mssn.send_cellphone_number(self.phone)  # 输入手机号码
     sleep(2)
     mssn.click_shopping_address()  # 点击收货地址输入框
     ap = AddressPage(self.driver)
     sleep(2)
     ap.send_search_address_input(self.address)  # 输入地址信息
     ap.click_search_address_show_dfgc()  # 点击显示为成都锦江区229号的结果
     sleep(2)
     mssn.send_building_number(self.building_number)
     sleep(2)
     mssn.click_school_lable()  # 点击学校标签
     mssn.click_Save_the_shipping_address()  #点击保存收货地址
Ejemplo n.º 10
0
 def setup(self):
     self.main = MainPage()
     self.address = AddressPage()
Ejemplo n.º 11
0
class TestCategoryPage:
    def setup(self):
        self.driver = get_driver()
        self.category_page = CategoryPage(self.driver)
        self.category_page.switch_to_category_page()

    def teardown(self):
        self.driver.quit()

    @allure.step(title='测试:分类页的搜索功能')
    @pytest.mark.parametrize('arg', get_search_data())
    def test_search(self, arg):
        allure.attach('', '点击搜索框')
        self.category_page.click_search_box()
        allure.attach('', '输入搜索内容')
        self.search_page = SearchPage(self.driver)
        self.search_page.input_search_text(arg)
        allure.attach('', '开始搜索')
        self.search_page.click_search_for_button()
        allure.attach('', '检查是否跳转到搜索结果页,有截图')
        res = self.category_page.is_toast_exist('Comprehensive', True, '搜索结果页')
        assert res

    @allure.step(title='测试:点击分类页的“消息中心”图标时,页面是否正确跳转')
    def test_message_center_button(self):
        allure.attach('', '点击消息中心')
        self.category_page.click_message_center_img()
        allure.attach('', '检查是否跳转到消息中心页,有截图')
        res = self.category_page.is_toast_exist('通知', True, '消息中心页')
        assert res

    @allure.step(title='测试:左侧商品类目标签能否正常切换')
    def test_toggle_category(self):
        allure.attach('', '点击服饰标签')
        self.category_page.click_clothes_tab()
        allure.attach('', '检查是否展示服饰类商品')
        assert self.category_page.is_toast_exist('牛仔裤')
        allure.attach('', '点击电脑标签')
        self.category_page.click_computer_tab()
        allure.attach('', '检查是否展示电脑类商品')
        assert self.category_page.is_toast_exist('一体机')
        allure.attach('', '点击家居标签')
        self.category_page.click_household_tab()
        allure.attach('', '检查是否展示家居类商品')
        assert self.category_page.is_toast_exist('保温杯')
        allure.attach('', '点击鞋类标签')
        self.category_page.click_shoes_tab()
        allure.attach('', '检查是否展示鞋类商品')
        assert self.category_page.is_toast_exist('休闲鞋')
        allure.attach('', '点击手机标签')
        self.category_page.click_cellphone_tab()
        allure.attach('', '检查是否展示手机类商品')
        assert self.category_page.is_toast_exist('游戏手机')

    @allure.step(title='测试:从分类页选购商品的业务流程')
    def test_buy_something(self):
        allure.attach('', '点击手机标签中的手机数码类目')
        self.category_page.click_cellphone_goods()
        allure.attach('', '选择荣耀畅玩6')
        self.goods_list_page = GoodsListPage(self.driver)
        self.goods_list_page.swipe_screen('up')
        self.goods_list_page.choose_goods()
        allure.attach('', '查看商品详情')
        self.goods_info_page = GoodsInfoPage(self.driver)
        self.goods_info_page.click_details_tab()
        allure.attach('', '查看评价')
        self.goods_info_page.click_comments_tab()
        allure.attach('', '返回商品购买页')
        self.goods_info_page.click_goods_tab()
        allure.attach('', '收藏商品')
        self.goods_info_page.click_collect_img()
        allure.attach('', '选择规格')
        self.goods_info_page.click_specification_button()
        allure.attach('', '选择全网通4G版')
        self.goods_info_page.click_version_4G_radio()
        allure.attach('', '数量加1')
        self.goods_info_page.click_plus_button()
        allure.attach('', '立即购买')
        self.goods_info_page.click_buy_now_button()
        allure.attach('', '选择收获地址')
        self.confirm_order_page = ConfirmOrderPage(self.driver)
        self.confirm_order_page.click_address_button()
        allure.attach('', '选择nero的地址')
        self.address_page = AddressPage(self.driver)
        self.address_page.click_address_of_nero_button()
        allure.attach('', '提交订单')
        self.confirm_order_page.click_submit_orders_button()
        res = self.category_page.is_toast_exist('支付方式', True, '立即支付页')
        assert res
Ejemplo n.º 12
0
 def get_page_address(self):
     """获取page_address对象"""
     return AddressPage()
Ejemplo n.º 13
0
class TestAddAddress:
    def setup(self):
        # 创建一个字典,包装相应的启动参数
        desired_caps = dict()
        # 需要连接的手机的平台(不限制大小写)
        desired_caps['platformName'] = 'Android'
        # 需要连接的手机的版本号(比如 5.2.1 的版本可以填写 5.2.1 或 5.2 或 5 ,以此类推)
        desired_caps['platformVersion'] = '5.1'
        # 需要连接的手机的设备号(andoird平台下,可以随便写,但是不能不写)
        desired_caps['deviceName'] = '192.168.56.101:5555'
        # 需要启动的程序的包名
        desired_caps['appPackage'] = 'com.yunmall.lc'
        # 需要启动的程序的界面名
        desired_caps[
            'appActivity'] = 'com.yunmall.ymctoc.ui.activity.MainActivity'
        # 告诉appium不重置应用
        desired_caps['noReset'] = True
        # 支持中文
        desired_caps['unicodeKeyboard'] = True
        desired_caps['resetKeyboard'] = True
        # 连接appium服务器
        self.driver = webdriver.Remote('http://*****:*****@pytest.mark.parametrize('args',
                             analyze_data('address_data',
                                          'test_add_address_case'))
    def test_add_address_case(self, args):
        name = args['name']
        phone = args['phone']
        address = args['address']
        postcode = args['postcode']
        # 关闭更新
        self.home_page.click_close_update()
        # 点击我的
        self.home_page.click_my_button()
        # 点击设置
        self.my_page.click_set_button()
        # 点击地址管理
        self.my_page.click_adress_button()
        # 点击新增地址
        self.address_page.click_add_address()
        # 点击输入姓名
        self.add_address_page.input_name(name)
        # 点击输入手机号码
        self.add_address_page.input_phone(phone)
        # 点击省市区
        self.add_address_page.click_province()
        # 点击添加输入详细地址
        self.add_address_page.input_address(address)
        # 点击输入邮编
        self.add_address_page.input_postcode(postcode)
        # 点击选择默认地址
        self.add_address_page.click_default_address()
        # 点击保存
        self.add_address_page.click_save()
        # 断言 新增默认地址是否是预期
        assert self.address_page.get_default_name_phone_text() == '%s  %s' % (
            name, phone)
Ejemplo n.º 14
0
class Shopping():
    def __init__(self, driver):
        self.home = HomePage(driver)
        self.user_center = UserCenter(driver)
        self.login = LoginPage(driver)
        self.address = AddressPage(driver)
        self.goods_detial = GoodsDetail(driver)
        self.confirm_order = ConfirmOrder(driver)

    def shopping_flow(self, username, password, data):
        #在首页点击我的进入用户中心
        self.home.click_user_center()
        #点击个人中心的头像进入登陆界面
        self.user_center.click_address()
        #登录
        self.login.input_username(username)
        self.login.input_password(password)
        self.login.click_login()
        #新建一个地址
        time.sleep(6)
        self.user_center.click_address()
        self.address.click_add_new_address()
        self.address.input_consignee_name(data["consignee_name"])
        self.address.input_consignee_mobile(data["consignee_mobile"])
        self.address.choose_consignee_region()
        self.address.input_consignee_address(data["consignee_address"])
        self.address.click_save_address()

        #回到首页
        self.home.click_home()
        #选择商品
        self.home.click_goods()
        #点击立即购买
        time.sleep(5)
        self.goods_detial.click_buy_now()
        self.goods_detial.click_confirm()
        #使用积分和余额付款
        self.confirm_order.click_order_point()
        self.confirm_order.click_order_balance()
        #点击提交订单
        time.sleep(5)
        self.confirm_order.click_submit()
        self.confirm_order.input_pay_passwd("111111")
        self.confirm_order.click_confirm_pay()
        # 点击用户中心
        self.home.click_user_center()
        self.user_center.click_my_order()
        order_number = self.user_center.get_order_number()
        return order_number
Ejemplo n.º 15
0
class TestAddReceivingAddress(unittest.TestCase):
    def setUp(self) -> None:
        # 打开浏览器到添加收货地址界面
        # 创建对象
        driver = open_browser()
        self.login = AddressPage(driver)
        # 准备数据,进入到添加收货地址界面
        url = "http://172.16.1.224/ecshop/"
        self.login.open_url(url)
        self.login.login_address("grj123456", "grj123456")
        # 得到最后一个数据的索引,就可以进行添加操作了
        self.a = self.login.a_number()
        self.login.performance(self.a)

    def tearDown(self) -> None:
        # 关闭浏览器
        self.login.close()

    @ddt.data(*test_data)
    def test_add_receiving_address(self, data):
        """测试用例,添加收货地址"""
        # 1.选择国家
        self.login.select_country(data["country"])
        # 2.选择省份
        self.login.select_province(data["province"])
        # 3.选择城市
        self.login.select_city(data["city"])
        # 4.选择区域
        if data["district"] != "None":
            self.login.select_district(data["district"])
        # 5.输入收货人姓名
        self.login.input_consignee(data["consignee"])
        # 6.输入邮箱
        if data["email"] != "None":
            self.login.input_email(data["email"])
        # 7.输入详细地址
        self.login.input_address(data["address"])
        # 8.输入邮政编码
        if data["zipcode"] != "None":
            self.login.input_zipcode(str(data["zipcode"]))
        # 9.输入电话
        if data["tel"] != "None":
            self.login.input_tel(str(data["tel"]))
        # 10.输入手机
        if data["mobile"] != "None":
            self.login.input_mobile(str(data["mobile"]))
        # 11.点击添加
        self.login.click_submit()
        # 12.隐式等待,找到对应的数据
        self.login.driver.implicitly_wait(5)
        # 13.断言,判断用例是否执行成功
        result = self.login.is_add_success(self.a)
        self.assertEqual(result, data["expect"])
class TestModifyReceivingAddress(unittest.TestCase):
    def setUp(self) -> None:
        # 打开浏览器到添加收货地址界面
        # 创建对象
        driver = open_browser()
        self.login = AddressPage(driver)
        # 准备数据,进入到添加收货地址界面
        url = "http://172.16.1.224/ecshop/"
        self.login.open_url(url)
        self.login.login_address("grj123456", "grj123456")

    def tearDown(self) -> None:
        # 关闭浏览器
        self.login.close()

    @ddt.data(*test_data)
    def test_modify_receiving_address(self, data):
        """测试用例,修改地址"""
        # 1.获取输入的id,然后根据id来进行定位要修改的地址
        b = self.login.a_number()
        a = data["id"] - 1
        if a < b:
            self.login.performance(a)
        else:
            print("需要修改的地址编号不存在")
            return False
        # 2.修改国家
        if data["country"] != "None":
            self.login.select_country(data["country"])
        # 3.修改省份
        if data["province"] != "None":
            self.login.select_province(data["province"])
        # 4.修改城市
        if data["city"] != "None":
            self.login.select_city(data["city"])
        # 5.修改区域
        if data["district"] != "None":
            self.login.select_district(data["district"])
        # 6.输入新收货人姓名
        if data["consignee"] != "None":
            self.login.input_consignee(data["consignee"])
        # 7.输入新邮箱
        if data["email"] != "None":
            self.login.input_email(data["email"])
        # 8.输入新详细地址
        if data["address"] != "None":
            self.login.input_address(data["address"])
        # 9.输入新邮政编码
        if data["zipcode"] != "None":
            self.login.input_zipcode(str(data["zipcode"]))
        # 10.输入新电话
        if data["tel"] != "None":
            self.login.input_tel(str(data["tel"]))
        # 11.输入新手机
        if data["mobile"] != "None":
            self.login.input_mobile(str(data["mobile"]))
        # 12.点击修改按钮
        self.login.click_modify()
        # 13.断言
        # 隐式等待
        self.login.driver.implicitly_wait(5)
        # 开始判断value值是否一致,一致就断言成功
        result = self.login.is_modify_success(data)
        self.assertEqual(result, data["expect"])
Ejemplo n.º 17
0
 def __init__(self, driver):
     self.driver = driver
     self.addresspage = AddressPage()
Ejemplo n.º 18
0
 def goto_address(self):
     # click add_member of main page
     self.find(By.XPATH, '//*[@id="menu_contacts"]').click()
     return AddressPage(self._driver)
Ejemplo n.º 19
0
 def address(self):
     return AddressPage(self.driver)
class TestDeleteReceivingAddress(unittest.TestCase) :
    i = 1
    def setUp(self) -> None:
        # 打开浏览器到添加收货地址界面
        # 创建对象
        driver = open_browser()
        self.login = AddressPage(driver)
        # 准备数据,进入到添加收货地址界面
        url = "http://172.16.1.224/ecshop/"
        self.login.open_url(url)
        self.login.login_address("grj123456","grj123456")
    def tearDown(self) -> None:
        # 关闭浏览器
        self.login.close()
    @ddt.data(*test_data)
    def test_delete_receiving_address(self,data):
        """测试用例,删除地址"""
        # 1.获取输入的id,然后根据id来进行定位要修改的地址
        b = self.login.a_number()
        a = data["id"]-self.i
        self.i += 1
        if a < b :
            self.login.performance(a)
        else :
            print("需要修改的地址编号不存在")
            return False
        # 1.根据得到的a值,可以定位到删除按钮,点击删除
        self.login.click_delete()
        # 2.跳出弹框,获取弹窗
        alert = self.login.driver.switch_to.alert
        # 3.点击弹框确认按钮
        alert.accept()
        # 刷新窗口
        self.login.driver.refresh()
        # 2.隐式等待,找到对应的数据
        self.login.driver.implicitly_wait(5)
        # 3.断言,判断用例是否执行成功
        result = self.login.is_delete_success(b)
        self.assertEqual(result,data["expect"])