def check_order_first_item(_item_view): """ 检查普通订单的商品信息,如果是购物车订单,该方法检查第一件商品的信息 :return: """ try: item_name_info = locate_by_anchor(_item_view, child_lv='v0l1l0v0') item_name_info_text = get_text_of_view(item_name_info) sku_id = locate_by_anchor(_item_view, child_lv='v0l1l0v1') sku_id_text = get_text_of_view(sku_id) sku_properties_name1 = locate_by_anchor(_item_view, child_lv='v0l1l0v2v0') sku_properties_name2 = locate_by_anchor(_item_view, child_lv='v0l1l0v2v1') sku_properties_name3 = locate_by_anchor(_item_view, child_lv='v0l1l0v2v2') sku_properties_name1_text = get_text_of_view(sku_properties_name1) sku_properties_name2_text = get_text_of_view(sku_properties_name2) sku_properties_name3_text = get_text_of_view(sku_properties_name3) res1 = sku_properties_name1_text == ITEM_INFO.get('属性')[0] res2 = sku_properties_name2_text == ITEM_INFO.get('属性')[1] res3 = sku_properties_name3_text == ITEM_INFO.get('属性')[2] res = res1 and res2 and res3 if item_name_info_text != ITEM_INFO.get('商品标题'): return False, '订单商品标题显示不正确' if sku_id_text != ITEM_INFO.get('商家编码'): return False, '订单的商家编码信息显示不正确' if not res: return False, '订单的sku属性信息显示不正确' return True, '' except PocoNoSuchNodeException: return False, '订单商品部分界面异常或者数据异常,请重新检查用例设计'
def check_order_addressee(_addressee_view): try: #addressee_info = locate_by_anchor(_addressee_view, child_lv='v0l1') addressee_info_text= poco(text = '顾超').get_text() addressee_info_pos = poco(text = '顾超').get_position()[0] addressee_pos = poco(text = '收件人').get_position()[0] #addressee_info_text = get_text_of_view(addressee_info) #mobile_info = locate_by_anchor(_addressee_view, child_lv='v0l1l1') mobile_info = poco(text = '186-2172-9133') mobile_info_text = mobile_info.get_text() mobile_info_pos = poco(text = '186-2172-9133').get_position()[0] address_info = locate_by_anchor(_addressee_view, child_lv='v1l1') address_info_text = get_text_of_view(address_info) # address = poco(text = '收货地址') # address_pos = address.get_position()[0] # address_info_text = poco(text = '上海,上海市,宝山区,高境镇新二路55号皇冠,201900').get_text() if addressee_info_text != ORDER_INFO.get('收件人姓名') and addressee_info_pos != addressee_pos: return False, '订单的收件人姓名信息显示不正确' if mobile_info_text != ORDER_INFO.get('收件人手机f') and addressee_info_pos != mobile_info_pos: return False, '订单的收件人手机号信息显示不正确' if address_info_text != ORDER_INFO.get('收货地址'): return False, '订单的收货地址信息显示不正确' return True, '' except PocoNoSuchNodeException: return False, '订单收货信息部分界面异常或者数据异常,请重新检查用例设计'
def check_buyer_no_alipay(self): buyer_no_alipay = init_element(self.buyer_no_alipay_locator) locate_by_anchor(buyer_no_alipay, 1, 'l0').click() if get_text_of_view(locate_by_anchor( buyer_no_alipay, 1, 'l0')).encode('utf-8') == b'\xee\x9a\x9d': return True else: return False
def choose_medium(self): insert = init_element(self.insert_locator) medium = locate_by_anchor(insert, parent_lv=5, child_lv='v1l1l0') medium.click() if get_text_of_view(medium) == b'\\ue69d': return True else: return False
def choice_second_default_reminder(self): new = init_element(self.recommended_phrase_locator) # 第二条短语的选择按钮 chang_two = locate_by_anchor(new, parent_lv=2, child_lv='v2v2v0v0l0') chang_two.click() chang_two_text = locate_by_anchor(chang_two, parent_lv=4, child_lv='v0') chang_two_text = get_text_of_view(chang_two_text) return chang_two_text
def check_white_ww(self): white_ww = init_element(self.white_ww_locator) locate_by_anchor(white_ww, 1, 'l0').click() if get_text_of_view(locate_by_anchor( white_ww, 1, 'l0')).encode('utf-8') == b'\xee\x9a\x9d': return True else: return False
def choose_bad_batch(self): insert = init_element(self.insert_phrase_button_locator) good = locate_by_anchor(insert, parent_lv=5, child_lv='v0l2l0') good.click() if get_text_of_view(good) == '\ue69d': return True else: return False
def check_cloud_bad(self): cloud_bad = init_element(self.cloud_bad_locator) locate_by_anchor(cloud_bad, 1, 'l0').click() if get_text_of_view(locate_by_anchor( cloud_bad, 1, 'l0')).encode('utf-8') == b'\xee\x9a\x9d': return True else: return False
def choose_bad(self): insert = init_element(self.insert_locator) bad = locate_by_anchor(insert, parent_lv=5, child_lv='v1l2l0') bad.click() if get_text_of_view(bad) == b'\\ue69d': return True else: return False
def choice_first_default_reminder(self): new = init_element(self.recommended_phrase_locator) # 第一条短语的选择按钮 change_one = locate_by_anchor(new, parent_lv=2, child_lv='v1v2v0v0l0') change_one.click() chang_one_text = locate_by_anchor(change_one, parent_lv=4, child_lv='v0') chang_one_text = get_text_of_view(chang_one_text) return chang_one_text
def check_order_addressee_detail_page(self, _addressee_view): try: addressee_info = locate_by_anchor(_addressee_view, child_lv='v0l1') addressee_info_text = get_text_of_view(addressee_info) mobile_info = locate_by_anchor(_addressee_view, child_lv='v0l1l1l0') mobile_info_text = get_text_of_view(mobile_info) address_info = locate_by_anchor(_addressee_view, child_lv='v1l1') address_info_text = get_text_of_view(address_info) if addressee_info_text != ORDER_INFO.get('收件人姓名'): return False, '订单的收件人姓名信息显示不正确' if mobile_info_text != ORDER_INFO.get('收件人手机f'): return False, '订单的收件人手机号信息显示不正确' if address_info_text != ORDER_INFO.get('收货地址'): return False, '订单的收货地址信息显示不正确' return True, '' except PocoNoSuchNodeException: return False, '订单收货信息部分界面异常或者数据异常,请重新检查用例设计'
def check_black_block(self): black_block = init_element(self.black_block_locator) locate_by_anchor(black_block, 2, 'l0l0').click() if get_text_of_view(locate_by_anchor( black_block, 2, 'l0l0')).encode('utf-8') == b'\xee\x9a\x9d': return True else: return False
def check_give_me_bad_seller(self): bad_seller = init_element(self.give_me_bad_seller_locator) locate_by_anchor(bad_seller, 1, 'l0').click() if get_text_of_view(locate_by_anchor( bad_seller, 1, 'l0')).encode('utf-8') == b'\xee\x9a\x9d': return True else: return False
def get_order_status(self): block_buyer = init_element(self.block_buyer_locator) temp = locate_by_anchor(block_buyer, parent_lv=3, child_lv='v0') if len(temp.child()) < 4: status = locate_by_anchor(temp, child_lv='l0') else: status = locate_by_anchor(temp, child_lv='l1') return get_text_of_view(status)
def check_than_order_num(self): than_order_num = init_element(self.than_order_num_locator) locate_by_anchor(than_order_num, 1, 'l0').click() close_Elastic_frame('大于该件数').click() if get_text_of_view(locate_by_anchor( than_order_num, 1, 'l0')).encode('utf-8') == b'\xee\x9a\x9d': return True else: return False
def check_order_second_item(_item_view): try: item_name_info = locate_by_anchor(_item_view, child_lv='v1l1l0v0') item_name_info_text = get_text_of_view(item_name_info) sku_id = locate_by_anchor(_item_view, child_lv='v1l1l0v1') sku_id_text = get_text_of_view(sku_id) sku_properties_name1 = locate_by_anchor(_item_view, child_lv='v1l1l0v2v0') sku_properties_name1_text = get_text_of_view(sku_properties_name1) res = sku_properties_name1_text == ITEM_INFO_CART[1].get('属性') if item_name_info_text != ITEM_INFO_CART[1].get('商品标题'): return False, '购物车订单第二件商品标题显示不正确{},{}'.format(item_name_info_text, ITEM_INFO_CART[1].get('商品标题')) if sku_id_text != ITEM_INFO_CART[1].get('商家编码'): return False, '购物车订单第二件商品的商家编码信息显示不正确{}'.format(sku_id_text) if not res: return False, '购物车订单第二件商品的sku属性信息显示不正确' return True, '' except PocoNoSuchNodeException: return False, '购物车订单商品部分界面异常或者数据异常,请重新检查用例设计'
def check_area_interception(self): area_interception = init_element(self.area_interception_locator) locate_by_anchor(area_interception, 1, 'l0').click() if get_text_of_view( locate_by_anchor(area_interception, 1, 'l0')).encode('utf-8') == b'\xee\x9a\x9d': return True else: return False
def get_price(self): """ 通过相对定位找到价格元素 获取并返回文本内容,即订单总价 :return: """ anchor = init_element(self.total_price_locator) total_price = locate_by_anchor(anchor, parent_lv=1, child_lv='l3l1') total_price_text = get_text_of_view(total_price) return total_price_text
def check_following_keywords(self): following_keywords = init_element(self.following_keywords_locator) locate_by_anchor(following_keywords, 1, 'l0').click() close_Elastic_frame('以下关键字拦截').click() if get_text_of_view( locate_by_anchor(following_keywords, 1, 'l0')).encode('utf-8') == b'\xee\x9a\x9d': return True else: return False
def check_than_actual_payment(self): than_actual_payment = init_element(self.than_actual_payment_locator) locate_by_anchor(than_actual_payment, 1, 'l0').click() close_Elastic_frame('大于该金额').click() if get_text_of_view( locate_by_anchor(than_actual_payment, 1, 'l0')).encode('utf-8') == b'\xee\x9a\x9d': return True else: return False
def check_white_baby(self): white_baby = init_element(self.white_baby_locator) locate_by_anchor(white_baby, 1, 'l0').click() button = poco(text='黑名单中买家依旧拦截') locate_by_anchor(button, 1, 'l0').click() if get_text_of_view(locate_by_anchor( button, 1, 'l0')).encode('utf-8') == b'\xee\x9a\x9d': return True else: return False
def insert_phrase(self): insert = init_element(self.insert_phrase_button_locator) insert.click() phrase_temp = init_element(self.phrase_locator) phrase = randomize(phrase_temp) expect_text = get_text_of_view(phrase) phrase.click() phrase_text_box = init_element(self.phrase_text_box_locator) actual_text = phrase_text_box.get_text() if expect_text == actual_text: return True, actual_text else: return False, actual_text
def white_baby_operation(): baby_status = {} poco(text='添加宝贝白名单').click() poco(text='添加宝贝白名单').wait_for_appearance(3) poco(text='添加宝贝白名单').click() first_baby = poco(text='添加')[0] baby_name_demo = locate_by_anchor(first_baby, parent_lv=2, child_lv='l0l1') baby_name = get_text_of_view(baby_name_demo) first_baby.click() if poco(text=baby_name).exists(): baby_status['add'] = True locate_by_anchor( poco(text=baby_name), parent_lv=3, child_lv='l1').offspring('android.widget.Button').click() else: baby_status['add'] = False if poco(text=baby_name).exists(): baby_status['move'] = False else: baby_status['move'] = True return baby_status
def get_following_keywords(self): following_keywords = init_element(self.following_keywords_locator) following_keywords_news = locate_by_anchor(following_keywords, 2, 'v1l0v0') following_keywords_news = get_text_of_view(following_keywords_news) return following_keywords_news
def get_default_reminder(self): news = init_element(self.default_reminder_locator) default_news = locate_by_anchor(news, parent_lv=4, child_lv='v0') default_news = get_text_of_view(default_news) return default_news