def scenetask_namecancel(self): self.scenetask_name() # 情景任务编辑页面,名称弹窗 self.find_xpath(excel.xpath_con('renameInput')).send_keys(u'哈哈123') # 输入名称哈哈123 time.sleep(1) self.find_xpath(excel.xpath_con('giveup_edit_cancel')).click() # 点击取消按钮 time.sleep(1) return self.find_item('哈哈123')
def timing_name_sure(self): self.timing_name() # 定时任务,名称弹窗 self.find_xpath(excel.xpath_con('renameInput')).send_keys(u'呵呵123') # 名称输入框输入新名称 呵呵123 time.sleep(1) self.find_xpath(excel.xpath_con('customScene_sure')).click() # 点击确定按钮 time.sleep(1) return self.find_item('呵呵123')
def giveup_edit2_sure(self): self.implement_finish() # 新建一个执行任务 self.find_xpath(excel.xpath_con('back')).click() # 点击左上返回按钮 time.sleep(1) self.find_xpath(excel.xpath_con('giveup_edit_sure')).click() # 点击确定按钮 time.sleep(1) return self.is_element('xpath', excel.xpath_con('housekeeper_list')) # 验证我的管家页面管家任务元素是否存在
def giveup_edit2_cancel(self): self.implement_finish() # 新建一个执行任务 self.find_xpath(excel.xpath_con('back')).click() # 点击左上返回按钮 time.sleep(1) self.find_xpath(excel.xpath_con('giveup_edit_cancel')).click() # 点击取消按钮 time.sleep(1) return self.is_element('xpath', excel.xpath_con('giveup_edit')) # 验证是否有弹窗
def timing_name_cancel(self): self.timing_name() # 定时任务,名称弹窗 self.find_xpath(excel.xpath_con('renameInput')).send_keys(u'呵呵123') # 名称输入框输入新名称 呵呵123 time.sleep(1) self.find_xpath(excel.xpath_con('addDelay_cancel')).click() # 点击取消按钮 time.sleep(1) return self.find_item('呵呵123')
def giveup_edit_sure(self): self.delay_task_finish() # 添加一个执行任务 self.find_xpath(excel.xpath_con('back')).click() # 点击左上返回按钮 time.sleep(1) self.find_xpath(excel.xpath_con('giveup_edit_sure')).click() # 点击确定按钮 time.sleep(1) return self.find_item('呵呵123') # 跳转我的管家页面,管家任务没有保存
def opened_state(self): self.find_xpath(excel.xpath_con('device')).click() # 点击设备 time.sleep(1) self.find_text('墙面插座').click() # 点击墙面插座 self.wait_ac(excel.activity_con('device_detail_activity')) if self.find_item(u'已关闭'): self.find_xpath(excel.xpath_con('socket_button')).click() time.sleep(2)
def editscene_back_exitsave(self): self.editscene_back() # 场景编辑页面,编辑的场景尚未保存弹窗 self.find_xpath(excel.xpath_con('editScene_leave_save')).click() # 点击退出保存按钮 time.sleep(2) self.long_press_custom(self.find_xpath(excel.xpath_con('first_scene'))) # 长按第一个场景 time.sleep(1) self.find_id(excel.id_con('popup_edit_scene_text_edit')).click() # 点击编辑场景 time.sleep(1) return self.find_item('墙面插座')
def editscene_edit(self): self.scene_open_socket() # 设置场景,插座打开 self.long_press_custom(self.find_xpath(excel.xpath_con('first_scene'))) # 长按第一个场景 time.sleep(1) self.find_id(excel.id_con('popup_edit_scene_text_edit')).click() # 点击编辑场景 time.sleep(2) self.find_xpath(excel.xpath_con('editscene_action_list')).click() # 点击第一个任务 time.sleep(1) return self.find_item('设置设备状态')
def zone_reduce(self): self.zone_add() # 创建一个分区,添加一个设备 self.find_xpath(excel.xpath_con('first_zone')).click() # 点击分区 time.sleep(2) self.find_xpath( excel.xpath_con('first_zone_reduce')).click() # 点击删除一个设备 time.sleep(2) self.driver.back() return self.find_item('0个设备')
def editscene_back(self): self.scene_page() # 全部场景页面,删除已有场景 time.sleep(1) self.find_id(excel.id_con('all_scene_image_add')).click() # 点击创建场景 self.wait_ac(excel.activity_con('add_scence_activity')) # 场景名称与图标页面 time.sleep(1) self.find_xpath(excel.xpath_con('go_out')).click() # 点击离家场景图标 time.sleep(1) self.find_xpath(excel.xpath_con('customScene_input_name')).send_keys(u'呵呵123') time.sleep(1) self.find_xpath(excel.xpath_con('customScene_sure')).click() # 点击确定按钮 time.sleep(2) self.find_xpath(excel.xpath_con('editScene_add_equipment')).click() # 点击添加任务按钮 time.sleep(1) self.switch_h5() # 切换到H5页面 self.find_xpath(excel.xpath_con('socket_scene')).click() # 点击墙面插座 time.sleep(1) self.switch_app() # 切回原生 self.find_xpath(excel.xpath_con('socket_open')).click() # 点击开 time.sleep(1) self.find_xpath(excel.xpath_con('finish_delay')).click() # 点击右上完成按钮 time.sleep(2) self.find_xpath(excel.xpath_con('editScene_goback')).click() # 点击左上返回按钮 time.sleep(1) return self.is_element('xpath', excel.xpath_con('editScene_leave_scene')) # 判断弹窗元素是否存在
def modify_zone(self): self.least_one_zone() # 前置条件,至少一个分区,设备列表页面 time.sleep(1) self.click_device(u'墙面插座') # 点击墙面插座 self.wait_ac(excel.activity_con('device_detail_activity')) self.find_xpath(excel.xpath_con('more')).click() # 点击右上更多按钮 time.sleep(1) self.find_id(excel.id_con('item_device_more_area')).click() # 点击分区 time.sleep(1) self.find_xpath(excel.xpath_con('more_first_zone')).click() # 点击第一个分区 return self.find_toast('修改设备区域成功')
def create_scene_cancel(self): self.old_gateway_mine() # 账号登陆,绑定网关,我的页面 self.find_xpath(excel.xpath_con('find')).click() # 点击智能按钮 time.sleep(1) self.find_id(excel.id_con('all_scene_image_add')).click() # 点击创建场景 time.sleep(2) self.find_xpath(excel.xpath_con('go_sleep')).click() # 点击回家场景图标 time.sleep(1) self.find_content_desc('javascript:;').click() # 点击左上返回按钮 self.wait_ac(excel.activity_con('all_scence_activity')) # 全部场景页面 return self.find_item('睡眠')
def find_password_page_2(self): self.sign_in_page() # 登录页面 self.login('16558785250', 'v987456321') # 错误密码登录 n = 0 while not self.find_item('您的账号或密码不正确,是否找回密码?') and n < 4: self.find_xpath(excel.xpath_con('login')).click() # 登录 time.sleep(3) n = n + 1 self.find_xpath(excel.xpath_con('find_password')).click() # 点击找回密码按钮 time.sleep(1) return self.find_item('获取验证码') # 验证是否进入找回密码页面
def zone_add(self): self.old_gateway_mine() # 账号登陆,绑定网关,我的页面 self.zone_manage_page() # 进入分区管理页面 self.delete_zone_all() # 删除全部分区 self.creat_zone('自动化测试:分区管理010-011') # 创建分区 self.find_xpath(excel.xpath_con('first_zone')).click() # 点击分区 time.sleep(2) self.find_xpath(excel.xpath_con('first_zone_add')).click() # 点击添加一个设备 time.sleep(2) self.driver.back() return self.find_item('1个设备')
def code_page_wrongcode(self): self.register() # 注册页面 self.find_text('手机号/邮箱').send_keys('18013980000') self.find_text('获取验证码').click() # 点击获取验证码按钮 time.sleep(1) self.find_xpath(excel.xpath_con('code_1')).send_keys('1') self.find_xpath(excel.xpath_con('code_2')).send_keys('2') self.find_xpath(excel.xpath_con('code_3')).send_keys('3') self.find_xpath(excel.xpath_con('code_4')).send_keys('9') time.sleep(2) return self.find_item('验证码错误')
def create_scene_back(self): self.old_gateway_mine() # 账号登陆,绑定网关,我的页面 self.find_xpath(excel.xpath_con('find')).click() # 点击智能按钮 time.sleep(1) self.find_id(excel.id_con('all_scene_image_add')).click() # 点击创建场景 time.sleep(2) self.find_xpath(excel.xpath_con('go_home')).click() # 点击回家场景图标 time.sleep(1) self.find_content_desc('完成').click() # 点击完成按钮 time.sleep(3) self.driver.back() self.wait_ac(excel.activity_con('all_scence_activity')) # 全部场景页面 return self.find_item('回家')
def no_name_scene(self): self.old_gateway_mine() # 账号登陆,绑定网关,我的页面 self.find_xpath(excel.xpath_con('find')).click() # 点击智能按钮 time.sleep(1) self.find_id(excel.id_con('all_scene_image_add')).click() # 点击创建场景 time.sleep(2) self.find_xpath(excel.xpath_con('motion_mode')).click() # 点击运动场景图标 time.sleep(1) self.find_xpath(excel.xpath_con('customScene_input_name')).send_keys( '') # 输入kong场景名称 self.find_content_desc('完成').click() # 点击完成按钮 time.sleep(3) return self.find_item('场景名称') and self.find_item('场景图标')
def longpress_cancel(self): self.old_gateway_mine() # 账号登陆,绑定网关,我的页面 self.find_xpath(excel.xpath_con('find')).click() # 点击智能按钮 time.sleep(1) if not self.page_id(excel.id_con('scene_content')): # 如果没有场景就创建一个场景 self.creat_scene('自动化008') self.long_press_custom(self.find_xpath( excel.xpath_con('first_scene'))) # 长按第一个场景 time.sleep(1) self.find_id( excel.id_con('popup_edit_scene_text_cancel')).click() # 点击取消 time.sleep(1) return self.find_item('取消')
def log_close(self): self.emptying_record_sure() # 清空日志消息,更多页面 self.driver.back() time.sleep(1) self.find_xpath(excel.xpath_con('socket_button')).click() # 点击开关按钮 time.sleep(2) self.find_xpath(excel.xpath_con('socket_button')).click() # 点击开关按钮 time.sleep(2) self.find_xpath(excel.xpath_con('more')).click() # 点击右上更多按钮 time.sleep(1) self.find_id(excel.id_con('item_device_more_root')).click() # 点击日志 time.sleep(2) return self.find_item('已关闭')
def bound_gateway(self): self.untie() # 登陆,如果绑定网关,解绑 self.find_xpath(excel.xpath_con('home')).click() self.find_id(excel.id_con('scene_icon')).click() # 点击场景,弹窗提示尚未绑定网关 time.sleep(2) self.find_id(excel.id_con('btn_bind')).click() # 点击去登录按钮 self.binding_gateway('50294D20B1FC', 'qazwsx1234') # 登录网关20B1FC self.find_id(excel.id_con('img_left')).click() # 点击返回按钮 self.find_xpath(excel.xpath_con('mine')).click() # 点击我的按钮 self.find_id(excel.id_con('item_gateway_center')).click() # 点击网关中心 time.sleep(2) text = self.get_text( excel.id_con('item_gateway_center_name')) # 获取网关中心网关名 return text
def bound_gateway_password5(self): self.untie() # 登陆,如果绑定网关,解绑 self.find_xpath(excel.xpath_con('home')).click() self.find_id(excel.id_con('scene_icon')).click() # 点击场景,弹窗提示尚未绑定网关 time.sleep(1) self.find_id(excel.id_con('btn_bind')).click() # 点击去登录按钮 self.find_id(excel.id_con('img_right')).click() # 点击网关列表右上角+按钮 time.sleep(1) self.find_xpath(excel.xpath_con('et_gateway_username')).send_keys( '50294D20B1FC') # 输入网关ID self.find_id(excel.id_con('et_gateway_password')).send_keys( 'wl123') # 输入网关密码 return self.find_id( excel.id_con('btn_gateway_login')).is_enabled() # 验证按钮是否可点击
def bound_gateway_wrong_password(self): self.untie() # 登陆,如果绑定网关,解绑 self.find_xpath(excel.xpath_con('home')).click() self.find_id(excel.id_con('scene_icon')).click() # 点击场景,弹窗提示尚未绑定网关 time.sleep(1) self.find_id(excel.id_con('btn_bind')).click() # 点击去登录按钮 self.find_id(excel.id_con('img_right')).click() # 点击网关列表右上角+按钮 time.sleep(1) self.find_xpath(excel.xpath_con('et_gateway_username')).send_keys( '50294D20B1FC') # 输入网关ID self.find_id(excel.id_con('et_gateway_password')).send_keys( 'wl123456') # 输入网关密码 self.find_id(excel.id_con('btn_gateway_login')).click() # 点击绑定网关按钮 return self.find_toast('设备密码错误')
def scene_close_socket(self): self.scene_page() # 全部场景页面,删除已有场景 time.sleep(1) self.find_id(excel.id_con('all_scene_image_add')).click() # 点击创建场景 self.wait_ac(excel.activity_con('add_scence_activity')) # 场景名称与图标页面 time.sleep(1) self.find_xpath(excel.xpath_con('go_out')).click() # 点击离家场景图标 time.sleep(1) self.find_xpath(excel.xpath_con('customScene_input_name')).send_keys(u'哈哈123') time.sleep(1) self.find_xpath(excel.xpath_con('customScene_sure')).click() # 点击确定按钮 time.sleep(2) self.find_xpath(excel.xpath_con('editScene_add_equipment')).click() # 点击添加任务按钮 time.sleep(1) self.switch_h5() # 切换到H5页面 self.find_xpath(excel.xpath_con('socket_scene')).click() # 点击墙面插座 time.sleep(1) self.switch_app() # 切回原生 self.find_xpath(excel.xpath_con('socket_close')).click() # 点击关 time.sleep(1) self.find_xpath(excel.xpath_con('finish_delay')).click() # 点击右上完成按钮 time.sleep(1) self.find_xpath(excel.xpath_con('finishScene')).click() # 点击保存按钮 self.wait_ac(excel.activity_con('all_scence_activity')) # 全部场景页面 return self.find_item('哈哈123')
def longpress_delete_cancel(self): self.old_gateway_mine() # 账号登陆,绑定网关,我的页面 self.find_xpath(excel.xpath_con('find')).click() # 点击智能按钮 time.sleep(1) self.delete_scene_all() # 删除所有场景 self.creat_scene('自动化009') self.long_press_custom(self.find_xpath( excel.xpath_con('first_scene'))) # 长按第一个场景 time.sleep(1) self.find_id( excel.id_con('popup_edit_scene_text_delete')).click() # 点击删除 time.sleep(1) self.find_id(excel.id_con('dialog_btn_negative')).click() # 点击取消按钮 time.sleep(1) return self.find_item('自动化009')
def mine_housekeeper(self): self.old_gateway() # 账号登陆,绑定网关 self.driver.back() time.sleep(1) self.find_id(excel.id_con('scene_name')).click() # 点击我的管家 self.wait_ac(excel.activity_con('housekeeper_activity')) time.sleep(1) while True: if self.is_element('xpath', excel.xpath_con('housekeeper_list')): # 验证是否有场景任务 self.leftswip_housekeeper(2000) # 左划任务 time.sleep(1) self.find_xpath(excel.xpath_con('housekeeper_delete')).click() # 点击删除按钮 time.sleep(1) else: break
def click_the_scene_binding(self): self.untie() # 登陆,如果绑定网关,解绑 self.find_xpath(excel.xpath_con('home')).click() self.find_id(excel.id_con('scene_icon')).click() # 点击场景,弹窗提示尚未绑定网关 time.sleep(1) self.find_id(excel.id_con('btn_bind')).click() # 点击去登录按钮 return self.wait_ac(excel.activity_con('gateway_list')) # 验证网关列表页面T或者F
def click_trial_gateway(self): self.untie() # 登陆,如果绑定网关,解绑 self.find_xpath(excel.xpath_con('home')).click() self.find_id(excel.id_con('scene_icon')).click() # 点击场景,弹窗提示尚未绑定网关 time.sleep(1) self.find_id(excel.id_con('btn_virtual')).click() # 点击体验网关试用按钮 return self.find_toast('体验网关会在10分钟后自动解绑')
def forget_the_password(self): self.find_xpath(excel.xpath_con('mine')).click() # 点击我的按钮 self.log_out() # 如果已经登录,就退出,如果未登录,则不处理 self.find_id(excel.id_con('item_account_login_name')).click() self.wait_ac(excel.activity_con('signin_activity')) self.find_id(excel.id_con('login_error')).click() # 点击忘记密码按钮 time.sleep(1) return self.find_item('输入手机号或邮箱') # 验证页面是否有text输入手机号或邮箱
def next_step_not_clickable(self): self.find_xpath(excel.xpath_con('mine')).click() # 点击我的按钮 self.log_out() # 如果已经登录,就退出,如果未登录,则不处理 self.find_id(excel.id_con('item_account_login_name')).click() self.wait_ac(excel.activity_con('signin_activity')) self.find_id(excel.id_con('register')).click() # 点击注册按钮 time.sleep(2) return self.find_id(excel.id_con('tv_get_verification')).is_enabled() # 验证按钮是否可以点击