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 test_generate_bill(self): CardPage(self.driver).click_generate_bill() GenerateBillPage( self.driver).get_element_from_sql() # 根据SQL验证"生成账单"页面元素是否存在 GenerateBillPage( self.driver).click_generate_bill_button() # 点击"生成应付账单"按钮 GenerateBillPage( self.driver).assert_generate_bill_result() # 从SQL中验证结果 pass
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 _click_the_first_warehouse_card_ios(self, contract_type, rs_type, ele_no): """ 点击第一个卡片,判断里面的元素个数,如果不满足,就返回重新进 :param rs_type: :param contract_type: :param ele_no: """ if contract_type == 'DEMAND': ele_no = 16 if rs_type == 'RE': self.action.click(self.cc_supply_card_warehouse_area_locator, locator_order=[0]) # 点击第一个仓库面积卡片 i = 0 while len(get_elements(self.driver, self.all_ele)) != ele_no: CardPage(self.driver).back() sleep(5) self.action.click(self.cc_supply_card_warehouse_area_locator, locator_order=[0]) # 点击第一个仓库面积卡片 i += 1 if i > 4: break if rs_type == 'WA': self.action.click(self.cc_su_card_throughput_locator, locator_order=[0]) # 点击第一个吞吐量卡片 i = 0 while len(get_elements(self.driver, self.all_ele)) != ele_no: CardPage(self.driver).back() sleep(5) self.action.click(self.cc_su_card_throughput_locator, locator_order=[0]) # 点击第一个吞吐量卡片 i += 1 if i > 4: break 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 setUp(self): self.user_id = 13712345678 self.password = 123456 self.admin = 199795 self.udid = get_ios_udid() sleep(3) stop_ios_appium() start_ios_appium(self.udid) # 连接ios设备 self.desired_caps = {'platformName': 'iOS', 'deviceName': 'iPhone 6', '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) LoginPage(self.driver).login(self.user_id, self.password) CardPage(self.driver).click_long_card() # 恢复数据(sql) pass
def setUp(self): self.user_id = 10000237 self.invitee_id = 1111111003 # 用户账号从10000297变为428, 从迭代二数据结构变化导致的老账号失效 self.admin = 10000428 sleep(3) 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) #self.get_ui_locator(self.driver) LoginPage(self.driver).login(username=self.admin) # 登录 CardPage(self.driver).click_card_one() # 登入卡片一 pass
def setUp(self): self.user_id = 18888000003 self.admin = 199289 self.password = 123456 self.path = '/Users/cy/Downloads/test1107.xlsx' self.udid = get_ios_udid() sleep(3) 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 = app_web_driver.Remote('http://127.0.0.1:4723/wd/hub', self.desired_caps) sleep(2) # 浏览器的Driver self.browser = browser_web_driver.Firefox() sleep(1) delete_entity_shop(self.admin) sleep(2) LoginPage(self.driver).login(self.user_id, self.password) # 登录 CardPage(self.driver).click_card_one() # 卡片1
def setUp(self): self.udid = get_ios_udid() stop_ios_appium() start_ios_appium(self.udid) # 连接ios设备 self.desired_caps = { 'platformName': 'iOS', 'deviceName': 'iPhone 6 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=13311112222, password=123456) # 登录后手机桌面空白卡片 CardPage(self.driver).click_card_one() sleep(1) assert is_element_present(self.driver, ('ACCESSIBILITY_ID', '注册供应商')) pass
def test_Login2_001(self): LoginPage(self.driver).login(username=self.passwdus, password=123456) # 登录 CardPage(self.driver).click_card_one() # 卡片1 assert login_state(self.passwdus) == True
def FUN_ManagerAuthorization(self): # 管理者授权 # 普通监控者 1111111002登陆查看卡片和权限 self.driver.quit() # 退出重新登录被分配的用户 self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', self.desired_caps) LoginPage(self.driver).login(username=self.admin) # 登录 CardPage(self.driver).click_card_one() # 卡片1 # 一级管理者移交权限 permissions_199236_before = view_permissions( participant=self.admin, role_type='21') # 获取一级管理者的权限 sleep(20) while is_element_present(self.driver, ('ACCESSIBILITY_ID', 'icon back')): get_element(self.driver, ('ACCESSIBILITY_ID', 'icon back')).click() # 不稳定,有时候会跳转进具体卡片,而不是桌面 if is_element_present(self.driver, ['ACCESSIBILITY_ID', '管理者授权']): CardPage(self.driver).manager_authorization_card() # 进入管理者授权 # 移交权限:拿取容器,质检,下采购单,选择一级监控者用户 self.monitor_authorization_instant3 = MonitorAuthorization(self.driver) self.monitor_authorization_instant3.page_factory() self.monitor_authorization_instant3.assign_permission( self.transfer_jurisdiction_locator, u'一级监控者', permission_type1=self.take_container_locator, permission_type2=self.quality_testing_locator, permission_type3=self.purchase_order_locator) permissions_199236_after = view_permissions( participant=self.admin, role_type='21') # 移交权限后获取一级管理者的权限 permissions_199276_after = view_permissions( participant='199276', role_type='22') # 被移交人的管理者权限 self.tmp = [ u'拿取容器'.encode('utf-8'), u'质检'.encode('utf-8'), u'下采购单'.encode('utf-8') ] assert permissions_199236_before == permissions_199236_after and \ set(self.tmp).issubset(set(permissions_199276_after)) is True # 移交后,判断一级管理者和被分配者的权限 print('一级管理者移交权限给用户199276') # 一级管理者复制权限 CardPage(self.driver).click_card_one() # 卡片1 if is_element_present(self.driver, ['ACCESSIBILITY_ID', '管理者授权']): CardPage(self.driver).manager_authorization_card() # 进入管理者授权 # 复制权限:拣选商品,打印入库单,采购计划,选择一级监控者用户 self.monitor_authorization_instant3.assign_permission( self.copy_jurisdiction_locator, u'一级监控者', permission_type1=self.picking_goods_locator, permission_type2=self.print_receipt_locator, permission_type3=self.procurement_planning_locator) permissions_199236_after2 = view_permissions( participant=self.admin, role_type='21') # 复制权限后获取一级管理者的权限 # assert permissions_199236_before == permissions_199236_after2 # 经过复制分配后,一级管理者权限均不变,被分配者获取一级管理者所有权限 print('一级管理者复制权限给用户199276') # 普通管理者199276移交权限 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() # 进入管理者授权 sleep(1) # 移交权限:拿取容器,质检,下采购单,选择阿瑟用户 self.monitor_authorization_instant4 = MonitorAuthorization(self.driver) self.monitor_authorization_instant4.page_factory() self.monitor_authorization_instant4.assign_permission( self.transfer_jurisdiction_locator, u'阿瑟', permission_type1=self.take_container_locator, permission_type2=self.quality_testing_locator, permission_type3=self.purchase_order_locator) permissions_199276_after3 = view_permissions( participant='199276', role_type='21') # 移交权限后获取普通管理者的权限 permissions_1111111002_after = view_permissions( participant='1111111002', role_type='22') # 被移交人的管理者权限 # assert u'拿取容器'.encode('utf-8') not in permissions_199276_after3 and u'质检'.encode('utf-8') \ # not in permissions_199276_after3 and u'下采购单'.encode( # 'utf-8') not in permissions_199276_after3 \ # and set(self.tmp).issubset(set(permissions_1111111002_after)) is True # sql判断权限是否移交出去 print('普通管理者199276移交权限给1111111002') # 普通管理者199276复制权限权限 CardPage(self.driver).click_card_one() # 卡片1 if is_element_present(self.driver, ['ACCESSIBILITY_ID', '管理者授权']): CardPage(self.driver).manager_authorization_card() # 进入管理者授权 # 判断拿取容器、质检、下采购单是否还在 assert is_element_present(self.driver, self.take_container_locator) is False and \ is_element_present(self.driver, self.quality_testing_locator) is False and \ is_element_present(self.driver, self.purchase_order_locator) is False # 复制权限:拣选商品,打印入库单,采购计划,选择阿瑟用户 self.monitor_authorization_instant4.assign_permission( self.copy_jurisdiction_locator, u'阿瑟', permission_type1=self.picking_goods_locator, permission_type2=self.print_receipt_locator, permission_type3=self.procurement_planning_locator) permissions_199276_after4 = view_permissions( participant='199276', role_type='21') # 复制权限后获取普通管理者的权限 permissions_1111111002_after2 = view_permissions( participant='1111111002', role_type='22') # 被移交人的管理者权限 # assert permissions_199276_after3 == permissions_199276_after4 # 判断权限 print('普通管理者199276复制权限给1111111002') # 普通管理者1111111002登陆查看卡片和权限 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(3) while is_element_present(self.driver, ('ACCESSIBILITY_ID', 'icon back')): get_element(self.driver, ('ACCESSIBILITY_ID', 'icon back')).click() # 不稳定,有时候会跳转进具体卡片,而不是桌面 if is_element_present(self.driver, ['ACCESSIBILITY_ID', '管理者授权']): CardPage(self.driver).manager_authorization_card() # 进入管理者授权 assert is_element_present(self.driver, self.take_container_locator) is True and \ is_element_present(self.driver, self.quality_testing_locator) is True and \ is_element_present(self.driver, self.purchase_order_locator) is True and \ is_element_present(self.driver, self.picking_goods_locator) is True and \ is_element_present(self.driver, self.print_receipt_locator) is True and \ is_element_present(self.driver, self.procurement_planning_locator) is True pass
def full(self): # 临时增加了首页任务页面 # 临时的卡片中心,没有名称,通过XPAH临时进入 CardPage(self.driver).click_card_one() # 卡片1 CardPage(self.driver).click_select_service_scope() # 点击选择服务范围卡片 sleep(2) select_servcie_scope_instance = SelectServiceScope(self.driver) select_servcie_scope_instance.click_MakeProduction() # 搞生产 select_servcie_scope_instance.click_Freight() # 运货 select_servcie_scope_instance.click_ManageLabor() # 管劳务 # a = self.driver.find_element_by_xpath().is_enabled() # 判断是否高亮显示 # assert a == True select_servcie_scope_instance.click_Paydeposit() # 交纳保证金 if is_element_present(self.driver, ('ACCESSIBILITY_ID', '提交保证金')): get_element(self.driver, ('ACCESSIBILITY_ID', '提交保证金')).click() sleep(2) ChoosePayPage(self.driver).click_union_pay() # 选择银联支付 sleep(10) # g = self.driver.find_elements_by_class_name('UIATextField') # self.driver.find_element_by_class_name('UIATextField').send_keys("6216 2610 0000 0000 018 ") # self.driver.find_element_by_accessibility_id(u'下一步').click() get_element(self.driver, ['ACCESSIBILITY_ID', '下一步']).click() sleep(5) if is_element_present(self.driver, ('ACCESSIBILITY_ID', '确定')): get_element(self.driver, ['ACCESSIBILITY_ID', '确定']).click() get_element(self.driver, ['ACCESSIBILITY_ID', '下一步']).click() # self.driver.find_element_by_accessibility_id(u'证件号').send_keys("3411 2619 7709 2183 66") # self.driver.find_element_by_accessibility_id(u'免费获取').click() print('进入支付页面,调用银联支付') get_element(self.driver, ['ACCESSIBILITY_ID', '免费获取']).click() edit_elements = self.driver.find_elements_by_class_name('UIATextField') edit_elements[-1].set_value("123456") # self.driver.find_element_by_accessibility_id(u'完成').click() get_element(self.driver, ['ACCESSIBILITY_ID', '完成']).click() # self.driver.find_element_by_accessibility_id(u'确认付款').click() get_element(self.driver, ['ACCESSIBILITY_ID', '确认付款']).click() sleep(5) # self.driver.find_element_by_accessibility_id(u'返回商户').click() get_element(self.driver, ['ACCESSIBILITY_ID', '返回商户']).click() sleep(5) print('付款完成,返回商铺') # print() if is_element_present(self.driver, ['ACCESSIBILITY_ID', '确定需要的服务类型']): get_element(self.driver, ['ACCESSIBILITY_ID', '确定需要的服务类型']).click() get_element(self.driver, ['ACCESSIBILITY_ID', '可靠的保险']).click() get_element(self.driver, ['ACCESSIBILITY_ID', '选择好了']).click() if is_element_present(self.driver, ['ACCESSIBILITY_ID', '确定被服务的服务类型']): get_element(self.driver, ['ACCESSIBILITY_ID', '确定被服务的服务类型']).click() get_element(self.driver, ['ACCESSIBILITY_ID', '向我借钱']).click() get_element(self.driver, ['ACCESSIBILITY_ID', '完成']).click() if is_element_present(self.driver, ['ACCESSIBILITY_ID', '填写拥有的资产类型']): get_element(self.driver, ['ACCESSIBILITY_ID', '填写拥有的资产类型']).click() get_element(self.driver, ['ACCESSIBILITY_ID', '仓库']).click() get_element(self.driver, ['ACCESSIBILITY_ID', '选择好了']).click() pass