Ejemplo n.º 1
0
 def test_search_order_by_area(self):
     hp = HomePage(self.driver)
     sleep(1)
     hp.click(hp.order_qurey_locator)
     sleep(1)
     # 切换到main-frame
     bp = BasePage(self.driver)
     bp.switch_main_frame()
     sleep(1)
     # 选择地区
     oqp = OrderQueryPage(self.driver)
     hp.select(oqp.coutry_select_locator).select_by_index(1)
     sleep(1)
     hp.select(oqp.province_select_locator).select_by_index(1)
     sleep(1)
     hp.select(oqp.city_select_locator).select_by_index(1)
     sleep(1)
     hp.select(oqp.district_select_locator).select_by_index(1)
     sleep(1)
     # 点击搜索
     hp.click(oqp.click_search_locator)
     sleep(1)
     #断言
     hp.click(self.lookover_locator)
     sleep(1)
     text = hp.text(self.assert_adress_locator)
     self.assertIn(self.assert_adress, text)
Ejemplo n.º 2
0
class scannerPage:
    def __init__(self, driver):
        self.driver = driver
        self.base_page = BasePage(self.driver)
        # self.driver = self.base_page.driver
        self.get_by_local = GetByLocal(self.driver)

    def get_bleAlert_ok(self):
        """提示打开蓝牙弹出框的确定元素"""
        return self.get_by_local.get_element('bleok')

    def get_location_ok(self):
        """弹出定位权限弹出框的确定元素"""
        return self.get_by_local.get_element('locationOk')

    def get_driver(self):
        """ 已找到的"""
        return self.get_by_local.get_element('driverList')

    def get_driver_ok(self):
        """当点击已找到的设备会有二次对话框,返回确定元素"""
        return self.get_by_local.get_element('connectSure')

    def get_page_source(self):
        """获取页面所有元素"""
        page_source = self.base_page.get_page_source()
        return page_source

    def swipe_down(self):
        self.base_page.swipe_down()
Ejemplo n.º 3
0
class TestDemo:
    po_file = rootPath + '\\data\\page_demo.yaml'
    test_file = rootPath + '\\data\\test_search.yaml'
    data = Utils.from_file(test_file)

    def setup_class(self):
        self.app = BasePage()
        self.app.start()  # 调用start方法的时候就会赋值一个类属性_driver,后面就可以一直调用_driver了

    def teardown_class(self):
        self.app.stop()

    @pytest.mark.parametrize(data['key'], data['value'])
    def test_search(self, keyword):
        demo = DemoPage(self.po_file)
        demo.search(keyword=keyword)
        demo.back()

    def test_login(self):
        po_file1 = rootPath + '\\data\\page_login.yaml'
        login = CommonPage(po_file1)
        # 借助于__getattr__方法实现任意方法代理
        # login.xxxxx => login.__getattr__
        # 其实xxxxx用的就是CommonPage类的__getattr__方法中return的方法
        login.login_by_password(username="******", password="******")
Ejemplo n.º 4
0
 def setUp(self) -> None:
     lp = BroswerModel()
     self.driver = lp.broswer_chrome()
     DK = BasePage(driver=self.driver)
     DK.open()
     DL = LoginPage(driver=self.driver)
     username, password = data_Dl_ex()[0]
     DL.login(username, password)
     print("开始测试")
Ejemplo n.º 5
0
 def loaded(self, no_stock=True):
     locations = []
     while True:
         if no_stock:
             loc = BasePage().find(*self._optional)  # 检测主页是否加载完毕
         else:
             loc = BasePage().find(*self._stock_code)  # 检测自选股是否加载完毕
         locations.append(loc.location)
         if len(locations) >= 2 and locations[-1] == locations[-2]:
             break
Ejemplo n.º 6
0
    def setUp(self) -> None:
        print('写信测试')
        liulan = BroswerModel()  # 实例化一个浏览器类
        self.driver = liulan.broswer_chrome()  # driver重命名
        BP = BasePage(driver=self.driver)  # 引入一个driver
        BP.open()

        DL = LoginPage(driver=self.driver)
        username, password = data_Dl_ex()[1]
        DL.login(username, password)
Ejemplo n.º 7
0
 def test_delete_us(self):
     MyMethod().loaded()  # 检测首页是否加载完成
     BasePage().find(*self.optional).click()  # 点击自选按钮
     BasePage().find(*self.us_stock).click()  # 点击美股按钮
     stock_name = BasePage().element_exist(*self.stock_alibaba)
     if stock_name:  # 查找自选中是否有阿里巴巴股票
         sn = BasePage().find(*self.stock_alibaba)
         TouchAction(BaseView.get_driver()).long_press(sn).perform()
         BasePage().find(*self.stock_del).click()
     assert stock_name != True
Ejemplo n.º 8
0
 def test_exit_in_all(self):
     MyMethod().loaded()  # 检测首页是否加载完成
     BasePage().find(*self.optional).click()  # 点击自选按钮
     MyMethod().loaded(no_stock=False)  # 检测自选股是否加载完毕
     BasePage().find(*self.bmp_close).click()  # 点击BMP行情关闭按钮
     all_stocks = self.get_stocks(5)
     BasePage().find(*self.us_stock).click()  # 点击美股按钮
     MyMethod().loaded(no_stock=False)  # 检测美股是否加载完毕
     us_stocks = self.get_stocks(3)
     mystock= "阿里巴巴"
     assert mystock in all_stocks and mystock in us_stocks
Ejemplo n.º 9
0
    def login_case(self):
        self.b = BasePage()
        #找到账号、输入账号
        self.b.find_elemnt_and_click("android.widget.EditText"[0])
        self.b.get_send("android.widget.EditText"[0],"*****@*****.**")
        #找到密码、输入密码
        self.b.find_elemnt_and_click("android.widget.EditText")[1]
        self.b.get_send("android.widget.EditText"[1],"00000000")

        #登录
        self.b.find_elemnt_and_click("com.atom.cam:id/login_btn_login")
Ejemplo n.º 10
0
 def get_cookie(self):
     bp = BasePage(self.driver)
     lp = LoginPage(self.driver)
     bp.open(LOGIN_URL)
     self.send_keys(self.username_locator, self.username)
     self.send_keys(self.password_locator, self.password)
     self.click(self.login_button_locator)
     data = self.driver.get_cookies()[0]
     data = str(data)
     f = open('./cookie', "w")
     f.write(data)
     f.close()
Ejemplo n.º 11
0
 def login(self, username, password):
     self.open(self.url)
     self.ele_username(username)
     self.ele_password(password)
     self.ele_submit()
     time.sleep(2)
     shiji = BasePage.duanyan(self)
     return shiji
Ejemplo n.º 12
0
 def test_010(self):
     """MRYX_ST_shop010:验证购物车添加功能_购物车里增加商品的数量"""
     bp = BasePage(self.driver)
     bp.click(HomePage.sort_locator)
     bp.choose(SortPage.buy_locator, [1])
     bp.click(HomePage.cart_locator)
     cp = CartPage(self.driver)
     for i in range(4):
         cp.crease(1)
     """断言"""
     assert_number = bp.get_text(CartPage.cart_number_locator)
     self.assertEqual("5", assert_number)  ###断言
     cp = CartPage(self.driver)  ###删除购物车
     cp.drop_cart()  ###删除购物车
Ejemplo n.º 13
0
 def test_search_order_by_consignee_query(self):
     hp = HomePage(self.driver)
     sleep(1)
     hp.click(hp.order_qurey_locator)
     sleep(1)
     # 切换到main-frame
     bp = BasePage(self.driver)
     bp.switch_main_frame()
     sleep(1)
     # 输入收货人
     oqp = OrderQueryPage(self.driver)
     hp.send_keys(oqp.input_consignee_locator, self.consignee_name)
     # 点击搜索
     hp.click(oqp.click_search_locator)
     sleep(1)
     #断言
     op = OrderListPage(self.driver)
     text = hp.text(op.consignee_locator)
     self.assertIn(self.consignee_name, text)
Ejemplo n.º 14
0
 def test_search_order_by_adress(self):
     hp = HomePage(self.driver)
     sleep(1)
     hp.click(hp.order_qurey_locator)
     sleep(1)
     # 切换到main-frame
     bp = BasePage(self.driver)
     bp.switch_main_frame()
     sleep(1)
     # 输入地址
     oqp = OrderQueryPage(self.driver)
     hp.send_keys(oqp.input_adress_locator, self.adress_assert)
     # 点击搜索
     hp.click(oqp.click_search_locator)
     sleep(1)
     #断言
     op = OrderListPage(self.driver)
     text = hp.text(op.adress_locator)
     self.assertIn(self.adress_assert, text)
Ejemplo n.º 15
0
 def test_search_order_by_phonenumber(self):
     # 进入到订单页面
     hp = HomePage(self.driver)
     sleep(1)
     hp.click(hp.order_qurey_locator)
     sleep(1)
     # 切换到main-frame
     bp = BasePage(self.driver)
     bp.switch_main_frame()
     sleep(1)
     # 输入收手机号码
     oqp = OrderQueryPage(self.driver)
     hp.send_keys(oqp.input_phonenumber_locator, self.phonenumber)
     # 点击搜索
     hp.click(oqp.click_search_locator)
     sleep(1)
     #断言
     op = OrderListPage(self.driver)
     text = hp.text(op.phonenumber_locator)
     self.assertIn(self.phonenumber, text)
Ejemplo n.º 16
0
 def test_search_order_by_consignee(self):
     #进入到订单页面
     hp = HomePage(self.driver)
     sleep(1)
     hp.click(hp.orderlist_locator)
     sleep(1)
     # 切换到main-frame
     bp = BasePage(self.driver)
     bp.switch_main_frame()
     sleep(1)
     #输入收货人
     op = OrderListPage(self.driver)
     op.send_keys(op.input_consignee_locator, self.consignee_name)
     #订单状态选择最上面一项
     select = op.select(op.select_status_locator)
     select.select_by_value('-1')
     sleep(1)
     #点击搜索
     op.click(op.search_locator)
     sleep(1)
     #断言
     get_consignee_name = op.text(op.consignee_locator)
     self.assertEqual(self.consignee_name, get_consignee_name)
Ejemplo n.º 17
0
 def test_delete_case_cancelself(self):
     #进入订单页面
     hp = HomePage(self.driver)
     sleep(1)
     hp.click_orderlist()
     sleep(1)
     #切换到main-frame
     bp = BasePage(self.driver)
     bp.switch_main_frame()
     sleep(1)
     #选中订单
     op = OrderListPage(self.driver)
     op.click(op.click_order_locator)
     get_order_number = op.text(op.order_number_locator)
     #点击删除
     op.click(op.delete_locator)
     sleep(1)
     #弹出框点击确认删除
     self.driver.switch_to.alert.dismiss()
     sleep(4)
     get_order_number1 = op.text(op.order_number_locator)
     #断言
     self.assertEqual(get_order_number, get_order_number1)
Ejemplo n.º 18
0
 def test_MRYX_ST_usr_002(self):
     """注销登录测试"""
     bp = BasePage(self.driver)
     sleep(5)
     bp.click((By.ID, "cn.missfresh.application:id/mineTab"))  #点击我的
     sleep(1)
     bp.to_up(duration=3000)  # 上滑出现设置
     mp = MysPage(self.driver)  #实例化"我的"界面
     mp.click_set()  #点击设置按钮
     sleep(1)
     msp = MysSetPage(self.driver)  #实例化我的设置界面
     msp.click_sign_out()  # 点击退出登录
Ejemplo n.º 19
0
def pytest_runtest_makereport(item, call):
    """
    用例失败后自动截图
    """
    outcome = yield
    report = outcome.get_result()
    extra = getattr(report, 'extra', [])

    if report.when == 'call':
        xfail = hasattr(report, 'wasxfail')
        # 判断用例是否失败或者xfail跳过的测试
        if (report.skipped and xfail) or (report.failed and not xfail):
            # 获取测试用例代码中webDriver参数来获取浏览器进行抓屏
            for i in item.funcargs:
                if isinstance(item.funcargs[i], WebDriver):
                    # 截图
                    BasePage(item.funcargs[i]).capture_page_screen(
                        description='失败截图')
                    break
        report.extra = extra
Ejemplo n.º 20
0
 def test_MRYX_ST_usr_002(self):
     """注销登录测试"""
     bp = BasePage(self.driver)
     sleep(5)
     bp.click((By.ID, "cn.missfresh.application:id/mineTab"))  #点击我的
     sleep(1)
     bp.to_up(duration=3000)  # 上滑出现设置
     mp = MysPage(self.driver)  #实例化"我的"界面
     mp.click_set()  #点击设置按钮
     sleep(1)
     msp = MysSetPage(self.driver)  #实例化我的设置界面
     msp.click_sign_out()  # 点击退出登录
     hp = HomePage(self.driver)
     sleep(3)
     text = hp.text_quest_login()  # 获取立即登录的文本
     self.assertEqual(text, self.asserts)
Ejemplo n.º 21
0
class LoginPage:
    def __init__(self, driver):
        self.driver = driver
        self.base_page = BasePage(self.driver)
        # self.driver = self.base_page.driver
        self.get_by_local = GetByLocal(self.driver)

    def get_element(self, key, section='login_element'):
        return self.get_by_local.get_element(key, section)

    def account(self):
        self.get_element('account')

    def password(self):
        self.get_element('password')

    def forget(self):
        self.get_element('forget')

    def login(self):
        self.get_element('login')

    def register(self):
        self.get_element('register')

    def skip(self):
        self.get_element('skip')

    def toast_element(self, message):
        toast = self.base_page.get_toast_element(message)
        return toast

    def get_message(self):
        self.get_element('unlock_pattern_message')

    def unlock_pattern_no(self):
        self.get_element('unlock_pattern_no')
Ejemplo n.º 22
0
 def test_print_order(self):
     #进入订单页面
     hp = HomePage(self.driver)
     sleep(1)
     hp.click(hp.orderlist_locator)
     sleep(1)
     #切换到main-frame
     bp = BasePage(self.driver)
     bp.switch_main_frame()
     sleep(1)
     #选中订单
     op = OrderListPage(self.driver)
     op.click(op.click_order_locator)
     sleep(1)
     #点击打印订单
     op.click(op.print_locator)
     sleep(1)
     #切换到新开窗口订单打印界面
     bp.switch_window()
     #断言
     pp = PrintPage(self.driver)
     text = bp.text(pp.printorder_word_locator)
     self.assertEqual(self.assert_word, text)
Ejemplo n.º 23
0
 def tearDown(self):
     quit = BasePage(self.driver)  # 实例化BasePage
     quit.quit()  # 调用BasePage的quit()方法
     print('清理:退出')
Ejemplo n.º 24
0
 def setUp(self):
     '''打开登录页面'''
     lp = BroswerModel()
     self.driver = lp.broswer_chrome()
     dk = BasePage(driver=self.driver)
     dk.open()
Ejemplo n.º 25
0
 def __init__(self, driver):
     self.driver = driver
     self.base_page = BasePage(self.driver)
     # self.driver = self.base_page.driver
     self.get_by_local = GetByLocal(self.driver)
Ejemplo n.º 26
0
class MainPage:
    def __init__(self, driver):
        self.driver = driver
        self.base_page = BasePage(self.driver)
        # self.driver = self.base_page.driver
        self.get_by_local = GetByLocal(self.driver)

    def get_element(self, key, section='mainpage_element'):
        return self.get_by_local.get_element(key, section)

    def pairing_no(self):
        return self.get_element('pairingNO')

    def map1(self):
        return self.get_element('map1')

    def map2(self):
        return self.get_element('map2')

    def map3(self):
        return self.get_element('map3')

    def map4(self):
        return self.get_element('map4')

    def volume(self):
        return self.get_element('volume')

    def volume_sub(self):
        return self.get_element('volumeSub')

    def volume_add(self):
        return self.get_element('volumeAdd')

    def action_icon(self):
        return self.get_element('actionIcon')

    def map_name(self):
        return self.get_element('mapName')

    def mode_rich(self):
        return self.get_element('modeRich')

    def mode_normal(self):
        return self.get_element('modeNormal')

    def mic_or_aux(self):
        return self.get_element('mic/aux')

    def mic_and_aux(self):
        return self.get_element('mic+aux')

    def mic_and_tcoil(self):
        return self.get_element('mic+tcoil')

    def blue(self):
        return self.get_element('blue')

    def ctone_on(self):
        return self.get_element('ctoneON')

    def ctone_off(self):
        return self.get_element('ctoneOFF')

    def noise_on(self):
        return self.get_element('noiseON')

    def noise_off(self):
        return self.get_element('noiseOFF')

    def input_ratio2(self):
        return self.get_element('inputratio2')

    def input_ratio3(self):
        return self.get_element('inputratio3')

    def input_ratio5(self):
        return self.get_element('inputratio5')

    def input_ratio9(self):
        return self.get_element('inputratio9')

    def menu(self):
        return self.get_element('menu')

    def setting(self):
        return self.get_element('setting')

    def state(self):
        return self.get_element('state')

    def location(self):
        return self.get_element('location')

    def log(self):
        return self.get_element('log')

    def about(self):
        return self.get_element('about')

    def autoswitch(self):
        return self.get_element('autoswitch')

    def sceneON(self):
        return self.get_element('sceneON')

    def sceneOFF(self):
        return self.get_element('sceneOFF')

    def get_page_source(self):
        """获取页面所有元素"""
        page_source = self.base_page.get_page_source()
        return page_source

    def swipe_left(self):
        self.base_page.swipe_left()

    def swipe_right(self):
        self.base_page.swipe_right()
Ejemplo n.º 27
0
 def setup_class(self):
     base_page = BasePage()
     self.app = MainPage(base_page)
Ejemplo n.º 28
0
 def click_submit(self):  # 点击提交订单
     BasePage(self.driver).tap(870, 1855)
Ejemplo n.º 29
0
 def test_009(self):
     """MRYX_ST_shop009:验证购物车结算功能_取消部分勾选购物车商品"""
     bp = BasePage(self.driver)
     bp.click(HomePage.sort_locator)
     bp.choose(SortPage.buy_locator, [1, 2])
     bp.click(HomePage.cart_locator)
     """获取断言信息"""
     before_price = bp.order_text(CartPage.cart_price_locator, 2)
     ele = bp.find_elements(CartPage.choose_signal_locator)
     ele[1].click()
     after_price = bp.get_text(CartPage.all_prince_locator)
     """断言"""
     self.assertEqual(before_price, after_price)
     ele[1].click()
     cp = CartPage(self.driver)
     cp.drop_cart()
Ejemplo n.º 30
0
 def test_11(self):
     """MRYX_ST_shop011:验证购物车添加功能_购物车里减少商品的数量"""
     bp = BasePage(self.driver)
     bp.click(HomePage.sort_locator)
     bp.choose(SortPage.buy_locator, [1])
     for i in range(4):
         bp.choose(SortPage.repeat_add_locator, [1])
     bp.click(HomePage.cart_locator)
     for i in range(4):
         bp.click(CartPage.sub_locator)
     assert_number = bp.get_text(CartPage.cart_number_locator)
     self.assertEqual("1", assert_number)
     cp = CartPage(self.driver)
     cp.drop_cart()