def click_public_labor(self): """ 发布劳务需求 :return: """ if self.is_run_ios(): if is_element_present(self.driver, ('ACCESSIBILITY_ID', '发布劳务需求')): MainPage(self.driver).click_publish_labor_ios() self._publish_labour_ios() if not self.is_run_ios(): #LongCardPage(self.driver).click_expected_card(user_id=10001396, card_name='发布劳务需求') if is_element_present( self.driver, ("XPATH", "//*[@resource-id='com.iscs.mobilewcs:id/text' and @text='找劳务需求']" )): sleep(5) self.click_swipe_left(x1=1.5, y1=0.5, x2=0.2, y2=0.5, time=2000) self.click_swipe_left(x1=1.5, y1=0.5, x2=0.2, y2=0.5, time=2000) MainPage(self.driver).click_publish_labor_android() self._public_labour_android() pass
def FUN_DistributionManagerAndSupervisor(self): # 分配管理者和监控者,都分配给自己 reduction_monitor_and_manager_permissions() # 还原监控者管理者权限 reduction_distribution_manager_and_supervisor_task() # 还原分配监控者和管理者任务 if is_element_present(self.driver, ['ACCESSIBILITY_ID', '分配管理者和监控者']): CardPage(self.driver).distribution_manager_and_supervisor_card( ) # 分配管理者和监控者 get_elements(self.driver, self.assigned_to_me_locator)[0].click() # 监控者分配给我 get_element(self.driver, self.assigned_to_me_locator).click() # 管理者分配给我 get_element( self.driver, self.distribution_success_button_locator).click() # 点击分配成功\ sleep(20) while is_element_present(self.driver, ('ACCESSIBILITY_ID', 'icon back')): get_element(self.driver, ('ACCESSIBILITY_ID', 'icon back')).click() # 不稳定,有时候会跳转进具体卡片,而不是桌面 assert get_distribution_manager_and_supervisor_task_status() == 10 # and judge_manager_and_supervisor_result() is True # sql判断权限 assert is_element_present( self.driver, ('ACCESSIBILITY_ID', '分配管理者和监控者')) is False # 分配管理者和监控者卡片消失 assert get_element(self.driver, ('ACCESSIBILITY_ID', '管理者授权')).get_attribute('name'). \ encode('utf-8') == '管理者授权' # 生成管理者授权 assert get_element(self.driver, ('ACCESSIBILITY_ID', '监控者授权')).get_attribute('name'). \ encode('utf-8') == '监控者授权' # 生成监控者授权
def _login_android(self, username=None, password=None): """ android登录 :param username: :param password: :return: Update Cy """ if is_element_present(self.driver, ("XPATH", "//*[@resource-id='android:id/message' and @text='请登陆']")): sleep(4) self.action.click(("XPATH", "//*[@resource-id='android:id/button1' and @text='确定']")) pass if not is_element_present(self.driver, ('ID', 'btn_login_wechat')): ExitAppPage(self.driver).logout_app() if is_element_present(self.driver, ('ID', 'btn_login_wechat')): if username: print(self.user_name_locator) self.action.send_keys(self.user_name_locator, username) sleep(1) if password: self.action.send_keys(self.password_locator, password) self.action.click(self.login_button_locator) sleep(2) if is_element_present(self.driver, ("XPATH", "//*[@resource-id='android:id/message' and @text='是否绑定新设备']")): sleep(4) self.action.click(('XPATH', "//*[@resource-id='android:id/button1' and @text='绑定']")) pass
def eat_toast(self): """ 吃掉用户被顶以后系统的提示框:‘您的账号在别的地方登陆’ :return: :rtype: """ if GlobalVarClass.get_case_platform() == "darwin" and is_element_present(self.driver, ('ACCESSIBILITY_ID', self.toast_message)): self.action.click(self.driver, ('ACCESSIBILITY_ID', self.confirm)) elif is_element_present(self.driver, ("XPATH", "//*[@resource-id='android:id/message' and @text=%s]" % self.toast_message)): self.action.click(("XPATH", "//*[@resource-id='android:id/message' and @text=%s]" % self.confirm)) pass
def test_full2242(self): # 点击'发布劳务需求的任务'卡片 MainPage(self.driver).click_release_labor_demand() sleep(2) assert is_element_present(self.driver, ('ACCESSIBILITY_ID', '工种')) sleep(2) choose_labor_demand = LaborDemandPage(self.driver) choose_labor_demand.click_packing() choose_labor_demand.click_select_time() choose_labor_demand.click_select_address() assert is_element_present(self.driver, ('ACCESSIBILITY_ID', '浙江省 杭州市 西湖区')) choose_labor_demand.click_complete() pass
def click_publish_warehouse_supply(self): """ 发布仓储供应 :return: """ if self.is_run_ios(): if is_element_present(self.driver, ('ACCESSIBILITY_ID', '找劳务需求')): test_public_labour = PublishLabour(self.driver) # 滑动1次,滑到'发布仓储供应'卡片位置 test_public_labour.click_swipe_left(x1=1.5, y1=0.5, x2=0.2, y2=0.5, time=2000) main_page = MainPage(self.driver) main_page.click_publish_supply_ios() self._click_publish_warehouse_supply_ios() pass if not self.is_run_ios(): if is_element_present( self.driver, ("XPATH", "//*[@resource-id='com.iscs.mobilewcs:id/text' and @text='找劳务需求']" )): sleep(3) test_public_labour = PublishLabour(self.driver) # 滑动3次,滑到'发布仓储供应'卡片位置 test_public_labour.click_swipe_left(x1=1.5, y1=0.5, x2=0.2, y2=0.5, time=2000) sleep(3) test_public_labour.click_swipe_left(x1=1.5, y1=0.5, x2=0.2, y2=0.5, time=2000) sleep(3) test_public_labour.click_swipe_left(x1=1.5, y1=0.5, x2=0.2, y2=0.5, time=2000) main_page = MainPage(self.driver) main_page.click_publish_supply_android() self._click_publish_warehouse_supply_android() pass
def setUp(self): # 恢复测试数据 release_labor_demand() self.udid = get_ios_udid() stop_ios_appium() start_ios_appium(self.udid) # 连接ios设备 self.desired_caps = { 'platformName': 'iOS', 'deviceName': 'iPhone SE', 'device': 'iOS', 'bundleId': 'com.iscs.SmallAnimal', 'version': '9.3', 'udid': self.udid } self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', self.desired_caps) sleep(3) # 登录 LoginPage(self.driver).login(username=13588880000, password=123456) # 登录后手机桌面空白卡片 self.driver.find_element_by_xpath( "//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAScrollView[1]" "/UIACollectionView[1]/UIACollectionCell[2]").click() sleep(2) assert is_element_present(self.driver, ('ACCESSIBILITY_ID', '发布劳务需求')) pass
def login(self, username=None, password=None): if is_element_present(self.driver, ('ACCESSIBILITY_ID', '微信登录')): if username: self.action.set_value(self.user_name_locator, username) sleep(1) if password: self.action.set_value(self.password_locator, password) if is_element_present(self.driver, ('ACCESSIBILITY_ID', '完成')): sleep(1) self.action.click(('ACCESSIBILITY_ID', '完成')) self.action.click(self.login_button_locator) sleep(2) if is_element_present(self.driver, ('ACCESSIBILITY_ID', '绑定')): sleep(4) self.action.click(('ACCESSIBILITY_ID', '绑定')) pass
def click_up_delivery_order_ios(self): # 点击供方 self.action.click(self.supplier_locator) # 滑动需方单位 SwipeModel(self.driver).swipe_down(t=1000) # 选择确定 self.action.click(self.confirm_locator) # 点击需方 self.action.click(self.needs_locator) # 滑动需方单位 # 选择确定 self.action.click(self.confirm_locator) # 输入发货单号 self.action.set_value(self.invoice_number_locator, 'TX100008911') # 小键盘完成按钮 self.action.click(self.completeBtn_locator) # 到货地址 self.action.set_value(self.destination_locator, '江干区新加坡科技园2号楼23楼') # 小键盘完成按钮 self.action.click(self.completeBtn_locator) # 点击发货日期 self.action.click(self.ship_date_locator) # 发货日期确认 self.action.click(self.confirm_locator) # 点击去PC端导入 if is_element_present(self.driver, self.upload_file_locator): self.action.click(self.upload_file_locator) else: print("录入信息不完整")
def setUp(self): self.usr = 15511112222 self.pwd = 123456 # 删除数据 Restore_RegisterSupplier_SQL() self.udid = get_ios_udid() print(self.udid) sleep(3) stop_ios_appium() start_ios_appium(self.udid) # 连接ios设备 self.desired_caps = { 'platformName': 'iOS', 'deviceName': 'iPhone6 Plus', 'device': 'iOS', 'bundleId': 'com.iscs.SmallAnimal', 'version': '9.3', 'udid': self.udid } self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', self.desired_caps) sleep(3) LoginPage(self.driver).login(username=self.usr, password=self.pwd) # 登录 # 长期卡片 Common_Card_Page(self.driver).click_long_task() assert is_element_present(self.driver, ('ACCESSIBILITY_ID', '注册供应商')) pass
def click_the_first_labor_card_twice(self): sleep(5) self.action.click(self.la_start_time_locator, locator_order=[0]) if is_element_present(self.driver, self.msg_text_locator): self.driver.keyevent(4) # self.driver.back() sleep(5) self.action.click(self.la_start_time_locator, locator_order=[0])
def SetPromotionTemplate_TotalAmount_ios(self): # 通用满减金额类型模板 包括满足金额和减免金额 self.action.set_value(self.full_money_locator, '150000') self.action.set_value(self.minus_money_locator, '300') self.action.click(self.turn_complete_locator) # 小键盘的完成按钮 if is_element_present(self.driver, self.completeBtn_locator): self.action.click(self.completeBtn_locator) # 最后完成按钮 pass
def _depot_input_information_ios(self): self.action.set_value(self.input_depot_name_locator, u'起的隆冬强1') self.action.set_value(self.input_depot_address_locator, '下沙') self.action.set_value(self.click_depot_rent_locator, 346) self.action.set_value(self.input_depot_area_text_locator, 56515) self.action.click(self.click_map_locator) sleep(2) DepotMapPage(self.driver).map_first() if is_element_present(self.driver, ('ACCESSIBILITY_ID', '完成')): sleep(1) self.action.click(self.click_finish_button_locator) sleep(1) self.action.click(self.click_depot_activation_locator) sleep(3) assert is_element_present(self.driver, ('ACCESSIBILITY_ID', '激活成功')) self.action.click(self.click_ok_locator) pass
def NonServiceCertification004(self): if is_element_present(self.driver, ['ACCESSIBILITY_ID', '非服务认证']): CardPage(self.driver).click_non_service_certification_card() # 非服务认证 self.non_service_certification_instant = NonServiceCertification(self.driver) self.non_service_certification_instant.page_factory() self.non_service_certification_instant.wrong_two() sleep(1) pass
def operation_business_framework_task(self): self.action.click(self.click_who_am_I_locator) BusinessFrameworkTaskPage(self.driver).operation_who_i_business_framework_click() WhatIHavePage(self.driver).click_what_i_have_title() sleep(2) MySupplierPage(self.driver).click_my_supplier() MyCustomerPage(self.driver).task_click_my_customer_title() self.action.click(self.click_last_confirm_button_locator) assert is_element_present(self.driver, ('ACCESSIBILITY_ID', '签订系统供应契约')) pass
def wrong_two(self): self.image_click(0) get_element(self.driver, self.ta_locator).click() sleep(2) if is_element_present(self.driver, self.pass_locator): get_element(self.driver, ['ID', 'back']).click() sleep(2) for i in range(2): self.image_click(1) get_element(self.driver, self.ta_locator).click() self.image_click(1) sleep(2) elif is_element_present(self.driver, self.ta_locator): self.image_click(0) sleep(1) self.image_click(0) get_element(self.driver, self.ta_locator).click() sleep(2) print(u'两次审核失败')
def operation_bind_bank_card(self): self.action.set_value(self.input_user_name_locator, '测试账号') self.action.click(self.click_confirm_locator) sleep(2) if is_element_present(self.driver, ('ACCESSIBILITY_ID', '提示')): sleep(4) self.action.click(self.click_ok_locator) self.action.click(self.click_add_payment_account_locator) pass
def test_full2246(self): # 点击发布仓储供应的任务 MainPage(self.driver).click_release_warehouse() # 选择行业,吞吐量,价格,面积 warehouse = ReleaseWarehouse(self.driver) warehouse.click_storage_supply() # 选择时间 SelectTime(self.driver).click_confirm() assert is_element_present(self.driver, ('ACCESSIBILITY_ID', '立即发布')) # 点击立即发布 warehouse.click_immediately_release() pass
def FUN_TaskHandover(self): if is_element_present(self.driver, ['ACCESSIBILITY_ID', '非服务认证']): CardPage(self.driver).click_non_service_certification_card() # 非服务认证 self.swipe() sleep(5) if is_element_present(self.driver, ['ACCESSIBILITY_ID', 'icon send']) is False: self.swipe() # 移交任务,认证 self.task_handover_instant = TaskHandoverPage(self.driver) self.task_handover_instant.page_factory() self.task_handover_instant.handover() print('移交非服务认证任务') sleep(7) self.driver.quit() self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', self.desired_caps) LoginPage(self.driver).login(username=self.passwdine, password=123456) # 登录 CardPage(self.driver).click_card_one() # 卡片1 if is_element_present(self.driver, ['ACCESSIBILITY_ID', '刷新']): sleep(7) CardPage(self.driver).click_f5() # 刷新 sleep(7) CardPage(self.driver).click_f5() # 刷新 sleep(7) CardPage(self.driver).click_f5() # 刷新 if is_element_present(self.driver, ['ACCESSIBILITY_ID', '非服务认证']): CardPage(self.driver).click_non_service_certification_card() # 非服务认证 print('移交非服务认证任务给') self.non_service_certification_instant = NonServiceCertification(self.driver) self.non_service_certification_instant.page_factory() self.non_service_certification_instant.only_one(self.me) self.non_service_certification_instant.submit() sleep(1) # self.tmp2 = [u'拣选商品'.encode('utf-8'), u'打印入库单'.encode('utf-8'), # u'下采购单'.encode('utf-8'), u'非服务认证'.encode('utf-8')] self.driver.quit() self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', self.desired_caps) LoginPage(self.driver).login(username=self.passwdme, password=123456) # 登录 CardPage(self.driver).click_card_one() # 卡片1 sleep(2) print('认证通过,获取权限')
def FUN_NonServiceCertification(self): get_element(self.driver, self.yes_locator).click() get_element(self.driver, self.audit_pass_locator).click() sleep(1) self.tmp2 = [ u'拣选商品'.encode('utf-8'), u'打印入库单'.encode('utf-8'), u'下采购单'.encode('utf-8'), u'非服务认证'.encode('utf-8') ] self.driver.quit() self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', self.desired_caps) LoginPage(self.driver).login(username='******') # 登录 CardPage(self.driver).click_card_one() # 卡片1 sleep(2) if is_element_present(self.driver, ['ACCESSIBILITY_ID', '管理者授权']): CardPage(self.driver).manager_authorization_card() assert is_element_present(self.driver, self.print_receipt_locator) is True and \ is_element_present(self.driver, self.picking_goods_locator) is True and \ is_element_present(self.driver, self.purchase_order_locator) is True print('199276认证通过,199272获取权限')
def only_one(self, invitee_id): reduction_select(invitee_id) self.image_click(0) get_element(self.driver, self.ta_locator).click() sleep(2) for i in range(3): if is_element_present(self.driver, self.ta_locator): reduction_select(invitee_id) self.image_click(i + 1) get_element(self.driver, self.ta_locator).click() sleep(2) else: break
def test_DistributionManagerAndSupervisor(self): # print(is_element_present(self.driver, ['ACCESSIBILITY_ID', '分配代理人'])) # if is_element_present(self.driver, ['ACCESSIBILITY_ID', '分配代理人']): # CardPage(self.driver).distribution_manager_and_supervisor_card() # 分配代理人 # print(111) # sleep(3) DistributionManagerAndSupervisor( self.driver).distribution_manager_supervisor_to_self() sleep(25) while is_element_present(self.driver, ('ACCESSIBILITY_ID', 'icon back')): get_element(self.driver, ('ACCESSIBILITY_ID', 'icon back')).click() # 不稳定,有时候会跳转进具体卡片,而不是桌面
def wrong_two(self): # self.initial_element() self.image_click(0) get_element(self.driver, self.ta_locator).click() sleep(2) # for i in range(3): if is_element_present(self.driver, self.audit_pass_locator): get_element(self.driver, ['ACCESSIBILITY_ID', 'icon back']).click() sleep(2) for i in range(2): self.image_click(1) get_element(self.driver, self.ta_locator).click() self.image_click(1) sleep(2) elif is_element_present(self.driver, self.ta_locator): self.image_click(0) sleep(1) # get_element(self.driver, self.ta_locator).click() self.image_click(0) get_element(self.driver, self.ta_locator).click() sleep(2) is_element_present(self.driver, ['ACCESSIBILITY_ID', '刷新']) print(u'两次审核失败')
def _operation_transfer_task1_ios(self): mobile_size = self.driver.get_window_size() width = mobile_size['width'] height = mobile_size['height'] h = 479 / 1280.0 * height w = width * (424 / 637) self.driver.tap([(w, h)], 100) if is_element_present(self.driver, ('ACCESSIBILITY_ID', '非服务认证')): a = self.driver.find_elements_by_accessibility_id('非服务认证') a[0].click() print('任务分配已经确认') else: print('分配未成功,或者其他原因') assert False SwipeDown(self.driver) self.action.click(self.click_forward_locator) if is_element_present(self.driver, ('ACCESSIBILITY_ID', '转发该任务')): self.driver.find_element_by_accessibility_id('转发该任务').click() a = self.driver.find_elements_by_accessibility_id('选择') a[1].click() print(len(a)) self.action.click(self.click_sure_choice_locator) pass
def NonServiceCertification002(self): if is_element_present(self.driver, ['ACCESSIBILITY_ID', '非服务认证']): CardPage( self.driver).click_non_service_certification_card() # 非服务认证 self.non_service_certification_instant = NonServiceCertification( self.driver) self.non_service_certification_instant.page_factory() self.non_service_certification_instant.only_one(self.me) self.non_service_certification_instant.submit() sleep(1) print(u'认证通过') self.driver.quit() self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', self.desired_caps) LoginPage(self.driver).login(username=self.passwdme, password=123456) # 登录 CardPage(self.driver).click_card_one() # 卡片1 sleep(2) print('认证通过,获取权限') # self.tmp2 = [u'拣选商品'.encode('utf-8'), u'打印入库单'.encode('utf-8'), # u'下采购单'.encode('utf-8'), u'非服务认证'.encode('utf-8')] if is_element_present(self.driver, ['ACCESSIBILITY_ID', '管理者授权']): CardPage(self.driver).manager_authorization_card() # 管理者授权 pass
def FUN_TaskHandover(self): reduction_non_service_certification_task() restore_card() reduction_task() self.driver.quit() # 退出重新登录被分配的用户 self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', self.desired_caps) LoginPage(self.driver).login(username=self.user_id) # 登录 CardPage(self.driver).click_card_one() # 卡片1 if is_element_present(self.driver, ['ACCESSIBILITY_ID', '非服务认证']): CardPage( self.driver).click_non_service_certification_card() # 非服务认证 self.swipe() sleep(2) if is_element_present(self.driver, ['ACCESSIBILITY_ID', 'icon send']) is False: self.swipe() self.icon_send_ele = get_element(self.driver, self.icon_send_locator) self.icon_send_ele.click() get_element(self.driver, self.select_locator).send_keys(u'一级监控者') get_element(self.driver, self.select_locator).click() get_element(self.driver, self.forward_locator).click() # 转发 get_element(self.driver, self.hand_over_locator).click() # 确认移交 sleep(3) self.driver.quit() self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', self.desired_caps) LoginPage(self.driver).login(username=self.invitee_id) # 登录 CardPage(self.driver).click_card_one() # 卡片1 if is_element_present(self.driver, ['ACCESSIBILITY_ID', '非服务认证']): CardPage( self.driver).click_non_service_certification_card() # 非服务认证 print('199270移交非服务认证任务给199276') pass
def test_register_supplier(self): RegisterSupplier = RegisterSuppliersPage(self.driver) # 输入必填项 RegisterSupplier.input_required() sleep(1) # 选填项--接单人 RegisterSupplier.single_person() # 选填项--对账人 RegisterSupplier.reconciliation() # 选填项--付款人 RegisterSupplier.pay_person() # 点击付款 assert is_element_present(self.driver, ['ACCESSIBILITY_ID', '注册']) RegisterSupplier.register() pass
def login_ios(self, username=None, password=None): """ ios登录 :param username: 用户名 :param password: 密码 :return: """ if not is_element_present(self.driver, ('ACCESSIBILITY_ID', '微信登录')): ExitAppPage(self.driver).logout_app() if is_element_present(self.driver, ('ACCESSIBILITY_ID', '微信登录')): if username: print(self.user_name_locator) self.action.set_value(self.user_name_locator, username) sleep(1) if password: self.action.set_value(self.password_locator, password) if is_element_present(self.driver, ('ACCESSIBILITY_ID', '完成')): sleep(1) self.action.click(('ACCESSIBILITY_ID', '完成')) self.action.click(self.login_button_locator) sleep(2) if is_element_present(self.driver, ('ACCESSIBILITY_ID', '绑定')): sleep(4) self.action.click(('ACCESSIBILITY_ID', '绑定'))
def SetPromotionTemplate_PromotionTime_ios(self): # 设置促销时间 self.action.click(self.promotion_date_locator) # 确定按钮 self.action.click(self.confirm_locator) # 点击叠加模板 self.action.click(self.superposition_template_locator) # 输入模板说明 self.action.set_value(self.template_desc_locator, '这是一个临时的测试模板') # 点击小键盘的完成 self.action.click(self.s_completeBtn_locator) # 下一步 if is_element_present(self.driver, self.next_stepBtn_locator): self.action.click(self.next_stepBtn_locator) else: print("F**k shit!!")
def _entity_shop_input_information_ios(self): self.driver.hide_keyboard() # 关闭软键盘 self.action.set_value(self.input_entity_name_locator, '店大欺人啊') # get_element(self.driver, self.input_entity_name_locator).send_keys(u'店大欺人') self.action.set_value(self.input_entity_address_locator, '哈哈哈') self.action.set_value(self.input_entity_area_locator, '250') # get_element(self.driver, self.input_entity_area_locator).send_keys(250) self.action.click(self.click_map_locator) # get_element(self.driver, self.click_map_locator).click() sleep(2) DepotMapPage(self.driver).map_first() if is_element_present(self.driver, ('ACCESSIBILITY_ID', '完成')): sleep(1) self.action.click(self.click_finish_button_locator) self.action.click(self.click_next_button_locator) # get_element(self.driver, self.click_next_button_locator).click() sleep(10) pass