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 click_the_first_carriage_card(self, tr_card='发货量'): """ 点击第一个卡片,判断里面的元素个数,如果不满足,就返回重新进 :param tr_card: :param ele_no: """ if tr_card == '发货量': get_elements(self.driver, self.tr_card_locator)[7].click() # 点击第一个劳务卡片
def click_the_first_labor_card(self, contract_type='包装'): """ 点击第一个卡片,判断里面的元素个数,如果不满足,就返回重新进 :param contract_type: :param ele_no: """ if contract_type == '包装': get_elements(self.driver, self.la_card_packing_locator)[0].click() # 点击第一个劳务卡片 pass
def web_input_activation_commodity(self, path=None): a = get_elements(self.driver, self.click_activation_locator) a[0].click() get_element(self.driver, self.import_commodity_file_locator).send_keys(path) sleep(3) pass
def test_login_three_NextStepTwo(self): RegisterPage(self.driver).Click_WebChatLoginBtn_element() # 微信登录 sleep(2) self.driver.tap([(500, 990)], 500) sleep(2) Page_Register = RegisterPage(self.driver) self.driver.mobile.set_network_connection( self.driver.mobile.AIRPLANE_MODE) sleep(5) Page_Register.Click_NameTextInput_element() # 真实姓名: sleep(1) Page_Register.Click_IDCardNumText_element() # 输入身份证 sleep(1) Page_Register.Click_PhotographBtn_element() # 点击拍照认证 sleep(1) # 摄像头按钮 image_views = get_elements(self.driver, ("CLASS_NAME", "android.widget.ImageView")) image_views[7].click() sleep(1) self.driver.tap([(965, 15)], 500) # 点击勾 sleep(1) Page_Register.Click_DoneBtn_element() sleep(1) Page_Register.Click_NextStepBtn1_element() # 提示无网络 pass
def _get_the_first_warehouse_detail_info_ios(self, warehouse_type): """ 获取仓储详情页面的数据 """ supply_name = self.action.text(self.cc_supply_name_locator) # 发布者 detail_amount = self.action.text( self.cc_supply_detail_no_locator) # 详情数量 detail_unit = self.action.text( self.cc_supply_detail_unit_locator) # 详情单位 detail_start_time = self.action.text( self.cc_supply_detail_start_time_locator) # 详情开始时间 detail_end_time = self.action.text( self.cc_supply_detail_end_time_locator) # 详情结束时间 detail_price = self.action.text( self.cc_supply_detail_price_locator) # 价格 detail_instury = self.action.text( self.cc_supply_detail_instury_locator) # 行业 detail_overdue_clause = self.action.text( self.cc_supply_detail_overdue_clause_locator) # 逾期条款 if warehouse_type == 'supply': star_amount = len(get_elements(self.driver, self.star_locator)) # 星级 return supply_name, detail_amount, detail_unit, star_amount, detail_start_time, detail_end_time, \ detail_price, detail_instury, detail_overdue_clause else: return supply_name, detail_amount, detail_unit, detail_start_time, detail_end_time, \ detail_price, detail_instury, detail_overdue_clause pass
def _work_station_setting_page_one_android(self, Latitude): self.action.click() choose_depot = get_elements(self.driver, ("CLASS_NAME", "android.widget.RelativeLayout")) choose_depot[0].click() # 确定 self.action.click() # 选择需要变化的纬度:--物权 pass
def _work_station_setting_page_two_android(self, ): self.action.set_value(self.enter_station_name_locator, '拣选') self.action.click(self.choose_type_locator) jx = get_elements(self.driver, ("CLASS_NAME", "android.widget.RelativeLayout")) jx[0].click() self.action.click(self.choose_warehouse_confirmBtn_locator) self.action.click(self.completed_look_locator) pass
def operation_what_i_have(self): get_element(self.driver, self.click_online_retail_locator).click() get_element(self.driver, self.click_my_transport_locator).click() get_element(self.driver, self.click_car_locator).click() get_element(self.driver, self.click_my_staff_locator).click() get_element(self.driver, self.click_goods_locator).click() get_element(self.driver, self.click_entity_retail_locator).click() get_element(self.driver, self.click_material_factory_locator).click() get_element(self.driver, self.click_transport_supplier_locator).click() get_element(self.driver, self.click_depot_locator).click() get_element(self.driver, self.click_service_provider_locator).click() get_element(self.driver, self.click_finish_factory_locator).click() get_element(self.driver, self.click_storage_equipment_locator).click() get_element(self.driver, self.click_online_shop_locator).click() get_element(self.driver, self.click_entity_shop_locator).click() get_elements(self.driver, self.click_confirm_button_locator)[0].click() pass
def publish_goods_supply_android(self): self.action.click(self.inner_locator) # 点击内部 InnerUnit = get_elements( self.driver, ("CLASS_NAME", "android.widget.RelativeLayout")) # 内部业务单位 InnerUnit[1].click() self.action.click(self.back_locator) # 返回 self.action.click(self.outside_locator) # 点击外部 OutSideUnit = get_elements( self.driver, ("CLASS_NAME", "android.widget.RelativeLayout")) # 外部业务单位 OutSideUnit[3].click() self.action.click(self.back_locator) # 返回 if is_element_present(self.driver, self.complete_btn_locator): self.action.click(self.complete_btn_locator) # 发布 else: print("未找到该元素!") pass
def page_factory(self): name_list = ['ManageWarehouse', 'Paydeposit'] ele_dic = page_element_factory(__file__, name_list) self.managewarehouse_elements = get_elements(self.driver, ("ID", "tv_name")) self.paydeposit_element = get_element(self.driver, ele_dic['Paydeposit']) #缴纳保证金 return self.managewarehouse_elements #self.paydeposit_element = get_element(self.driver,ele_dic['Paydeposit']) pass
def _work_station_setting_page_one_android(self, Latitude): self.action.click(self.choose_warehouse_locator) choose_depot = get_elements( self.driver, ("CLASS_NAME", "android.widget.RelativeLayout")) choose_depot[0].click() # 确定 self.action.click(self.choose_warehouse_confirmBtn_locator) # 选择需要变化的纬度:--物权 wq = get_elements(self.driver, ("CLASS_NAME", "android.widget.RelativeLayout")) if Latitude == '所有': for i in wq: for xh in i: xh[0].click() xh[1].click() xh[2].click() xh[3].click() xh[4].click() xh[5].click() i[0] = '物权' i[1] = '委托' i[2] = '位置' i[3] = '品质' i[4] = '数量' i[5] = '组合' elif Latitude == '物权': wq1 = get_elements(self.driver, ("CLASS_NAME", "android.widget.RelativeLayout")) wq1[0].click(0) elif Latitude == '委托': wt = get_elements(self.driver, ("CLASS_NAME", "android.widget.RelativeLayout")) wt[1].click() elif Latitude == '位置': wz = get_elements(self.driver, ("CLASS_NAME", "android.widget.RelativeLayout")) wz[2].click() elif Latitude == '品质': pz = get_elements(self.driver, ("CLASS_NAME", "android.widget.RelativeLayout")) pz[3].click() elif Latitude == '数量': sl = get_elements(self.driver, ("CLASS_NAME", "android.widget.RelativeLayout")) sl[4].click() elif Latitude == '组合': zh = get_elements(self.driver, ("CLASS_NAME", "android.widget.RelativeLayout")) zh[5].click() pass
def MobilePhoneForHw(self): PageFollow = FollowPage(self.driver) PageFollow.click_team_three_btn_element() # 点击伟大的三组button sleep(1) PageFollow.click_login_input_element() # 进入界面后,输入10000243 sleep(1) PageFollow.click_login_btn_element() # 点击登录 # 服务认证邀请 LinearLayout = get_elements( self.driver, ("CLASS_NAME", "android.widget.LinearLayout")) LinearLayout[3].click() PageFollow.click_select_friend_btn_element() # 选择好友 sleep(1) # 选择测试账号 Invite_Button = get_elements(self.driver, ("CLASS_NAME", "android.widget.Button")) Invite_Button[1].click() sleep(2) # 跳转至微信界并点击人物 self.driver.tap([(240, 590)], 500) sleep(2) # 分享按钮 self.driver.tap([(870, 1190)], 500) sleep(4) # 留在微信 # self.driver.tap([(757, 1055)], 500) self.driver.tap([(820, 1155)], 500) sleep(2) # 点击微信界面:测试账号 self.driver.tap([(240, 590)], 500) sleep(2) # 点击邀请链接 self.driver.tap([(620, 835), 500]) sleep(2) # 点击下载客户端右边按钮 self.driver.tap([(1015, 130), 500]) sleep(2) # 点击在浏览器中打开 -->跳入网仓三号 self.driver.tap([(900, 700), 500]) pass
def _forward_task_ios(self): """ IOS私有方法:任务转发 """ # self.action.click(self.forwardButton_locator) # 选择转发按钮 a = get_elements(self.driver, self.forwardButton_locator) a[1].click() self.action.click(self.forwardBySingle_locator) # 选择【转发该任务】 self.action.click(self.searchButton_locator) # 点击通讯录【搜索】按钮 self.action.send_keys(self.searchText_locator, '审') # 搜索框输入【审】 self.action.click(self.choiceButton_locator) # 点击【选择】按钮 self.action.click(self.saveButton_locator) # 点击【确认转发】按钮
def click_cross_border_button_android(self): # 选择日期 ''' 安卓端 :return: ''' self.action.click(self.chooseTime_locator) # 点击日期 self.action.click(self.confirmTimeBtn_locator) # 确定日期 self.action.click(self.chooseAddress_locator) # 选择地点 LinearLayout = get_elements( self.driver, ("CLASS_NAME", "android.widget.FrameLayout")) # 北京 北京市、宣武区 LinearLayout[1].click() LinearLayoutCity = get_elements( self.driver, ("CLASS_NAME", "android.widget.FrameLayout")) LinearLayoutCity[0].click() LinearLayoutLocation = get_elements( self.driver, ("CLASS_NAME", "android.widget.RelativeLayout")) LinearLayoutLocation[3].click() pass
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 test_login_three_NextStep(self): RegisterPage(self.driver).Click_WebChatLoginBtn_element() # 微信登录 sleep(2) self.driver.tap([(500, 990)], 500) sleep(2) Page_Register = RegisterPage(self.driver) Page_Register.Click_NameTextInput_element() # 真实姓名: sleep(2) Page_Register.Click_IDCardNumText_element() # 输入身份证 sleep(2) Page_Register.Click_PhotographBtn_element() # 点击拍照认证 image_views = get_elements( self.driver, ("CLASS_NAME", "android.widget.ImageView")) # 点击照相按钮 image_views[7].click() sleep(2) self.driver.tap([(965, 15)], 500) # 点击勾 sleep(1) Page_Register.Click_DoneBtn_element() # 点击应用该头像 sleep(1) Page_Register.Click_NextStepBtn1_element() # 点击下一步 sleep(1) Page_Register.Click_ChooseCountryCodeBtn_element() # 点击国家标码 self.driver.tap([(530, 1220)], 500) # 点击 USA 码 Page_Register.Click_MobilePhoneInputText_element( ) # 输入手机号152-6850-9694 sleep(1) Page_Register.Click_VerifyBtn_element() # 点击获取验证码 sleep(1) try: # 调用接口,返回数据进行判断 self.url = "http://192.168.200.136:8080/base/register/verifyCodeSms" parameter = {"mobile": "15268509694"} self.request = requests.post(self.url, json=parameter) self.values = self.request.json() if self.values['code'] == '0': # 在验证码栏位中输入错误验证码 Page_Register.Click_VerifyCodeText_element_Error() print("Testing:短信已收到,输入错误验证码!") Page_Register.Click_NestStepBtn2_element() # 点击下一步 sleep(1) # 点击获取验证码按钮 else: print("Testing:接口出错,无法发出json请求!") except Exception as e: print(e) pass
def web_input_activation_entity_shop(self, path=None): a = get_elements(self.driver, self.click_activation_locator) a[0].click() # elem = self.driver.find_element_by_css_selector(".position-abs") # try: # script = 'document.getElementsByClassName("position-abs")[0].click()' # ret = self.driver.execute_script(script) # alert = self.driver.switchTo().alert() # alert.sendKeys(path) # c = get_element(self.driver, self.import_commodity_file_locator) # script = '$(".position-abs").click()' # ret = self.driver.execute_script(script) # except Exception as e: # raise e get_element(self.driver, self.import_commodity_file_locator).send_keys(path) sleep(3) pass
def _click_the_first_carriage_card_ios(self): get_elements(self.driver, self.tr_type_locator)[0].click() # 点击第一个运输卡片
def assign_permission(self, assign_type, user_name, permission_type1=None, permission_type2=None, permission_type3=None, permission_type4=None, permission_type5=None, permission_type6=None): """ 选择权限,复制或者移交权限,搜索通讯录用户,分配权限,完成分配 :param assign_type: 复制或者移交 :param user_name: 通讯录名 :param permission_type1: 权限 :param permission_type2: 权限 :param permission_type3: 权限 :param permission_type4: 权限 :param permission_type5: 权限 :param permission_type6: 权限 """ self.initial_element() # 通讯录页面 self.mail_list_instant = MailListPage(self.driver) self.mail_list_instant.page_factory() self.search_locator = self.mail_list_instant.search_locator # 搜索 self.assign_locator = self.mail_list_instant.assign_locator # 分配 if permission_type1: get_elements(self.driver, permission_type1)[-1].click() # 选择权限 if permission_type2: get_elements(self.driver, permission_type2)[-1].click() # 选择权限 if permission_type3: get_elements(self.driver, permission_type3)[-1].click() # 选择权限 if permission_type4: get_elements(self.driver, permission_type4)[-1].click() # 选择权限 if permission_type5: get_elements(self.driver, permission_type5)[-1].click() # 选择权限 if permission_type6: get_elements(self.driver, permission_type6)[-1].click() # 选择权限 get_element(self.driver, assign_type).click() # 提交 get_element(self.driver, self.search_locator).send_keys(user_name) # 查询需要分配的用户 get_element(self.driver, self.search_locator).click() sleep(1) get_elements(self.driver, self.assign_locator)[-1].click() # 点击分配按钮 get_elements( self.driver, self.sure_assign_button_locator)[-1].click() # 确认分配页面,确认分配
def setUp(self): stop_android_appium() self.udid = get_android_udid() print(self.udid) self.desired_caps = { 'platformName': 'Android', 'version': '5.1.1', 'deviceName': '%s' % self.udid, 'appPackage': 'com.iscs.mobilewcs', 'appActivity': 'com.iscs.mobilewcs.activity.base.LauncherActivity', 'unicodeKeyboard': 'True', 'resetKeyboard': 'True' } start_android_appium(self.udid) self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', self.desired_caps) sleep(30) setFirstOne() # 还原task库注册信息 sleep(1) setSQlDelete_common() # 还原BASIC库注册信息 ''' Team3组开始 进行授权服务邀请:进入App后,点击伟大的三组button,进入界面后,输入10000243;点击登录 进入界面,点击服务认证邀请,进入邀请好友界面,点击选择好友BUTTON,选择张三,点击邀请button, 跳入微信,选择折耳喵,点击分享,点击返回网仓三号,点击退出。完成 ''' PageFollow = FollowPage(self.driver) PageFollow.click_team_three_btn_element() # 点击伟大的三组button sleep(1) PageFollow.click_login_input_element() # 进入界面后,输入10000243 sleep(1) PageFollow.click_login_btn_element() # 点击登录 # 服务认证邀请 LinearLayout = get_elements( self.driver, ("CLASS_NAME", "android.widget.LinearLayout")) LinearLayout[3].click() PageFollow.click_select_friend_btn_element() # 选择好友 sleep(1) # 选择测试账号 Invite_Button = get_elements(self.driver, ("CLASS_NAME", "android.widget.Button")) Invite_Button[1].click() sleep(2) # 跳转至微信界并点击人物 self.driver.tap([(240, 590)], 500) sleep(2) # 点击分享按钮 self.driver.tap([(870, 1190)], 500) sleep(4) # 留在微信 self.driver.tap([(820, 1155)], 500) sleep(2) # 点击测试账号 self.driver.tap([(540, 260)], 500) sleep(3) # 点击邀请链接 self.driver.tap([(561, 403)], 500) sleep(5) # 点击下载客户端右边按钮 105 self.driver.tap([(1015, 120)], 100) sleep(2) # 点击在浏览器中打开 -->跳入网仓三号 self.driver.tap([(900, 700)], 500) sleep(2) pass
def click_open_order_download_card(self): self.initial_element() get_elements(self.driver, self.open_order_download_locator)[2].click()
def open_order_download_card_text(self): self.initial_element() open_order_download_card_text = get_elements( self.driver, self.open_order_download_locator)[2].text print(open_order_download_card_text)