def test_switch_change_name(self, check_account, set_switch_name): """ 修改开关的设备名: 1. app首页点击进入设备主页,点击more进入设置界面 2.修改设备名称 【checkpoint】检查设置界面的昵称是否修改正确 3。返回设备主页 【checkpoint】检查设备主页界面的昵称是否修改正确 4。返回app主页 【checkpoint】检查app列表界面的昵称是否修改正确 :return: """ home_page.into_device_home_page(data.get_device('switch')) TestSwitch.switch_ready() new_name = data.get_device('switch') + switch_home_page.get_str() switch_home_page.into_setting() switch_setting_page.change_switch_name(new_name) GlobalVar.set_test_flag('t') assert new_name in switch_setting_page.read_switch_name( ), 'switch 修改昵称后设置界面名称错误' switch_setting_page.back_switch() time.sleep(3) assert new_name in switch_home_page.read_switch_name( ), 'switch 修改昵称后设备主页界面名称错误' switch_home_page.back_home() assert home_page.find_device(new_name), 'switch 修改昵称后设备列表名称错误'
def init_setup(self): global base_page, start_page, user_page, time_zone_page, system_page, news_page, change_pw_page, home_page, \ all_share_page, share_setting_page, add_device_page, device_help_page, help_faq_page, language_page GlobalVar.set_test_flag('f') base_page = BasePage(self.driver) start_page = StartPage(self.driver) home_page = HomePage(self.driver) user_page = UserPage(self.driver) time_zone_page = TimeZonePage(self.driver) system_page = SystemPage(self.driver) news_page = NewsPage(self.driver) change_pw_page = ChangePWPage(self.driver) all_share_page = AllSharePage(self.driver) share_setting_page = ShareSettingPage(self.driver) add_device_page = AddDevicePage(self.driver) device_help_page = DeviceHelpPage(self.driver) help_faq_page = HelpFAQPage(self.driver) language_page = LanguagePage(self.driver) # 检查ios升级弹窗 try: start_page.ignore_ios_update() except Exception as e: print('升级弹窗处理失败:\n' + e)
def test_switch_schedule_time(self, check_account, close_switch_schedule): """ 智能开关设置定时任务: 1.设置一个基于当前时间5min后的定时任务 【checklist】检查定时任务列表的时间是否设置正确 2.等待定时任务启动 【checklist】检查定时任务启动后灯泡的状态 :param check_account: :return: """ home_page.into_device_home_page(data.get_device('switch')) TestSwitch.switch_ready() if switch_home_page.read_deivce_status() == 'ON': switch_home_page.click_switch_btn() switch_home_page.into_schedules() _t = switch_schedule_page.add_new_schedule(data.get_device('switch'), 5) assert _t == switch_home_page.read_schedule_time( switch_schedule_page.week_simple_name), '定时任务设置正确' switch_schedule_page.back_switch() GlobalVar.set_test_flag('t') # 此处需要判断设备状态了 switch_home_page.long_wait(320) assert 'ON' in switch_home_page.read_deivce_status(), '定时任务执行启动成功'
def plugs_close_yellow_tip(self, plugs_close_yellow_tip, check_account): """ 智能插座被分享者修改设备名及小黄条显示: 1. app首页点击进入设备主页,修改一个定时任务 2.切换账号 [email protected],查看智能开关设备 【checkpoint】显示设备名称修改小黄条 :return: """ if home_page.find_device(data.get_device('plugs')) is False: assert False, '未查找到分享设备,无法执行用:[test_plugs_close_yellow_tip]' home_page.into_device_home_page(data.get_device('plugs')) TestPlug.plug_ready() plug_home_page.into_schedule() plug_schedule_page.click_away_mode() plug_schedule_page.back_plug() plug_home_page.back_home() TestPlug.change_account('plugs') home_page.into_device_home_page(data.get_device('plugs')) plug_home_page.skip_plug_guide() if plug_home_page.is_offline: plug_home_page.ok if plug_home_page.plug_is_offline() is False: assert False, 'plug 设备处于离线状态' plug_home_page.ignore_update() plug_home_page.into_schedule() GlobalVar.set_test_flag('t') assert plug_schedule_page.text_display( 'share modified the schedule'), '被分享人修改了定时任务未显示小黄条提示'
def test_white_bulbs_add_effect_favorite(self, check_account, delete_effect_favorite): """ 添加white模式的favorite: 1. app首页点击灯泡进入设备主页 2. 点击white模式,点击收藏,输入收藏名字f_white,点击保存 【checkpoint]】toast=Successfully Add 3.退出effect,点击favorite进入收藏列表,遍历列表 【checkpoint】列表显示f_white 4.点击f_white,返回灯泡主页 【checkpoint】灯效显示white :param check_account: :param effect:灯效 :return: """ home_page.into_device_home_page(data.get_device('white_bulbs')) TestBulbs.bulbs_ready() if bulbs_home_page.bulb_status(False) is False: bulbs_home_page.click_bulbs() time.sleep(4) bulbs_effect_page.add_favorite_effect('favorite') bulbs_effect_page.add_check_image('添加灯效收藏') GlobalVar.set_test_flag('t') bulbs_home_page.click_bulbs() bulbs_home_page.into_favorites(False) assert bulbs_favorite_page.find_favorite('favorite'), '未找到新添加的effect收藏'
def pytest_runtest_makereport(item): ''' hook pytest失败 :param item: :param call: :return: ''' outcome = yield rep = outcome.get_result() # we only look at actual failing test calls, not setup/teardown if rep.when == "call" and rep.failed: mode = "a" if os.path.exists("failures") else "w" with open("failures", mode) as f: # let's also access a fixture for the fun of it if "tmpdir" in item.fixturenames: extra = " (%s)" % item.funcargs["tmpdir"] else: extra = "" f.write(rep.nodeid + extra + "\n") global driver path = make_path() name = datetime.now().strftime('%m%d%H%M%S') path_name = u'{}/{}.png'.format(path, name) driver.get_screenshot_as_file(path_name) allure.attach.file(path_name, "【断言失败截图:{}.png】".format(name), allure.attachment_type.PNG) with open('{}'.format(path_name), "rb") as image_file: # 报错 TypeError: _log() got an unexpected keyword argument 'attachment' GlobalVar.get_rp_logger().info("断言失败截图", extra=dict(attachment={"name": "failure screenshot.png", "data": image_file, "mime": "image/png"}))
def switch_close_yellow_tip(self, switch_close_yellow_tip, check_account): """ 智能开关被分享者修改设备名及小黄条显示: 1. app首页点击进入设备主页,修改一个定时任务 2.切换账号 [email protected],查看智能开关设备 【checkpoint】显示设备名称修改小黄条 :return: """ if home_page.find_device(data.get_device('switch')) is False: assert False, '未查找到分享设备,无法执行用:[test_switch_close_yellow_tip]' home_page.into_device_home_page(data.get_device('switch')) TestSwitch.switch_ready() switch_home_page.into_schedules() switch_schedule_page.click_away_mode() switch_schedule_page.back_switch() switch_home_page.back_home() TestSwitch.change_account('switch') home_page.into_device_home_page(data.get_device('switch')) switch_home_page.skip_switch_guide() if switch_home_page.is_offline: switch_home_page.ok if switch_home_page.switch_is_offline() is False: assert False, 'switch 设备处于离线状态' switch_home_page.into_schedules() GlobalVar.set_test_flag('t') assert switch_schedule_page.text_display( 'share modified the schedule'), '被分享人修改了定时任务未显示小黄条提示'
def test_switch_change_name(self, check_account, set_plugs_name): """ 修改插座的设备名: 1. app首页点击进入设备主页,点击more进入设置界面 2.修改设备名称 【checkpoint】检查设置界面的昵称是否修改正确 3。返回设备主页 【checkpoint】检查设备主页界面的昵称是否修改正确 4。返回app主页 【checkpoint】检查app列表界面的昵称是否修改正确 :return: """ home_page.into_device_home_page(data.get_device('plugs')) TestPlug.plug_ready() new_name = data.get_device('plugs') + plug_home_page.get_str() plug_home_page.into_setting() plug_setting_page.change_device_name(new_name) GlobalVar.set_test_flag('t') assert new_name in plug_setting_page.read_device_name( ), 'plugs 修改昵称后设置界面名称错误' plug_setting_page.back_plug() assert new_name in plug_home_page.read_plug_name( ), 'plugs 修改昵称后设备主页界面名称错误' plug_home_page.back_home() assert home_page.find_device(new_name), 'plugs 修改昵称后设备列表名称错误'
def test_white_bulbs_schedule_time(self, check_account, close_bulbs_schedule): """ 球泡灯设置定时任务: 1.设置一个基于当前时间5min后的定时任务 【checklist】检查定时任务列表的时间是否设置正确 2.等待定时任务启动 【checklist】检查定时任务启动后灯泡的状态 :param check_account: :return: """ home_page.into_device_home_page(data.get_device('white_bulbs')) TestBulbs.bulbs_ready() if bulbs_home_page.bulb_status(False): bulbs_home_page.click_bulbs() bulbs_home_page.into_schedules(False) _t = bulbs_schedule_page.add_new_schedule(data.get_device('white_bulbs'), 5) assert _t == bulbs_schedule_page.read_schedule_time(bulbs_schedule_page.week_simple_name), '定时任务设置正确' bulbs_schedule_page.back_bulbs() GlobalVar.set_test_flag('t') # 此处需要判断设备状态了 bulbs_home_page.long_wait(320) assert bulbs_home_page.bulb_status(False), '定时任务执行启动成功'
def test_plug_schedule_time(self, check_account, close_plug_schedule): """ 智能插座设置定时任务: 1.设置一个基于当前时间5min后的定时任务 【checklist】检查定时任务列表的时间是否设置正确 2.等待定时任务启动 【checklist】检查定时任务启动后灯泡的状态 :param check_account: :return: """ home_page.into_device_home_page(data.get_device('plugs')) TestPlug.plug_ready() if plug_home_page.read_deivce_status() == 'ON': plug_home_page.click_plug_btn() plug_home_page.into_schedule() _t = plug_schedule_page.add_new_schedule(data.get_device('plugs'), 5) assert _t == plug_schedule_page.read_schedule_time( plug_schedule_page.week_simple_name), '定时任务设置正确' plug_schedule_page.back_plug() GlobalVar.set_test_flag('t') # 此处需要判断设备状态了 plug_home_page.long_wait(480) assert 'ON' in plug_home_page.read_deivce_status(), '定时任务执行启动成功'
def genie_add_device(self, check_account, reset_phone_network): """ 添加智能开关: 1. app首页点击+,选择switch,跳过引导页 2. 选择亚添加的设备id 3. 设置wifi,勾选 Status Confirmed,点击 next 4. 连接中,等待conecting消失 【checkpoint】判断是否显示添加成功(文本校验) 5. 修改设备昵称未T1100,点击保存 6. 返回设备主页查看设备列表 【checkpoint】首页列表刷新后显示插座T1100 :param check_account: :return: """ if GlobalVar.get_remove_add() == 0: GlobalVar.set_test_flag('f') pytest.skip('本次指定不执行词条用例') home_page.swipe_page('down') home_page.click_add_device() add_device_page.click_genie() add_device_page.select_switch_by_udid(data.get_device_udid('genie')) wifi_date = data.get_wifi('genie') add_device_page.select_wifi_with_switch(wifi_date[0], wifi_date[1]) add_device_page.wait_connect() assert add_device_page.connect_result(), 'genie 配网连接失败' add_device_page.set_device_name(data.get_device('genie')) add_device_page.loading() genie_page.back_home() home_page.swipe_page('down') assert home_page.find_device(data.get_device('genie')), 'genie 配网成功后首页未查找到设备'
def test_switch_agree_share(self, check_account, delete_share_news): """ 智能开关被分享者接受分享: 1. 登陆账号[email protected]/12345678 【checkpoint】登陆账号为[email protected] 2. 点击进入侧边栏界面 【checkpoint】消息通知显示分享通知红点标识 3. 点击news进入消息界面 【checkpoint】显示分享邀请消息记录 4. 点击最新一条分享邀请通知,点击ok按钮 【checkpoint】点击ok按钮弹窗提示分享成功 :param check_account: :return: """ home_page.into_device_home_page(data.get_device('switch')) TestSwitch.switch_ready() switch_home_page.into_setting() switch_setting_page.into_share() status = share_setting_page.read_share_status( data.get_username('share')) if status not in ['Awaiting Confirmation', 'Pending Confirmation']: share_setting_page.add_share() share_setting_page.commit_share(data.get_account('share')) assert share_setting_page.share_result( ), 'switch 正确账号分享失败,无法执行用例:[test_bulbs_agree_share]' share_setting_page.ok share_setting_page.loading() share_setting_page.back_setting() switch_setting_page.back_switch() switch_home_page.back_home() TestSwitch.change_account('share') home_page.into_system() system_page.into_sharing() assert all_share_page.text_display( data.get_device('switch')), '被分享列表未显示分享设备信息' GlobalVar.set_test_flag('t') # 到这里后需要执行 tear_down all_share_page.into_device(data.get_device('switch')) all_share_page.yes all_share_page.loading() assert all_share_page.text_display( 'Request Accepted. You may now use this device.'), '被分享者确认接受分享失败' all_share_page.ok assert all_share_page.text_display( 'switch shared a ' + data.get_device('switch').strip()), '被分享者显示的分享设备名称错误' news_page.back_system() news_page.back_system() system_page.back_home() home_page.swipe_page('down') assert home_page.find_device( data.get_device('switch')), '被分享者未显示分享的switch设备'
def test_switch_refuse_share(self, delete_share_news, check_account, delete_refuse_share_account): """ 智能开关被分享者拒绝接受分享: 1. 点击智能开关进入扫地机主页,点击 more进入设置界面,点击share setting进入分享列表 2. 点击 add 按钮进入添加界面,输入分享账号:[email protected]并提交 【checkpoint】 分享邀请发送成功,弹窗提示:Successed to share 3.重启app切换账号[email protected],进入分享消息记录 4.点击拒绝接受分享按钮 【checkpoint】显示已拒绝分享弹窗 【chenckpoint】app首页不显示分享设备 5.切换至分享者账号,检查分享列表 【checkpoint】不显示已拒绝的分享人 :param check_account: :return: """ home_page.into_device_home_page(data.get_device('switch')) TestSwitch.switch_ready() switch_home_page.into_setting() switch_setting_page.into_share() share_setting_page.add_share() share_setting_page.commit_share(data.get_account('refuseshare')) assert share_setting_page.share_result(), 'switch 正确账号分享失败' share_setting_page.ok share_setting_page.loading() share_setting_page.back_setting() switch_setting_page.back_switch() switch_home_page.back_home() TestSwitch.change_account('refuseshare') GlobalVar.set_test_flag('t') home_page.into_system() system_page.into_sharing() all_share_page.into_device(data.get_device('switch')) all_share_page.no assert all_share_page.text_display( 'Request Declined. This device will be removed.' ), 'switch 被分享者拒绝接受分享失败' all_share_page.ok all_share_page.loading() all_share_page.back_system() system_page.back_home() home_page.swipe_page('down') assert home_page.find_device( data.get_device('switch')) is False, 'app首页被分享者拒绝分享后显示分享了扫地机设备'
def appium_setup(request): """ 启动appium服务 :param request: :return: """ global device_sn, pf, server_ip, appium_port, appium_log_path, device_name, platform_version, wda_port, system_port, appium_p device_sn = cmd_sn(request) # 从执行命令读取测试手机sn号 pf = cmd_platform(request).lower() GlobalVar.set_add_remove(cmd_remove_add(request)) appium_port = util.create_port(server_ip, 4723, 7999) appium_log_path = "{}/src/appium_log/{}_{}.log".format(base_path.get_path(), datetime.now().strftime('%Y-%m-%d_%H.%M.%S'), appium_port) if pf == 'ios': GlobalVar.set_platform(GlobalVar.IOS) # 将平台名保存成全局的变量,脚本中通过GlobalVar.get_platform()获取当前执行的平台 # device_name = util.get_iphone_name(device_sn) device_name = 'iPhone eufy' platform_version = util.get_iphone_version(device_sn) wda_port = util.create_port(server_ip, 8100, 9999) appium_p = subprocess.Popen( "appium -a {} -p {} --webdriveragent-port {} --relaxed-security --session-override > {} 2>&1 &".format (server_ip, appium_port, wda_port, appium_log_path), shell=True) # 命令行启动appium服务 elif pf == 'android': GlobalVar.set_platform(GlobalVar.ANDROID) # 将平台名保存成全局的变量,脚本中通过GlobalVar.get_platform()获取当前执行的平台 util.uninstall_uiautomator2_server() # 卸载手机上安装的uiautomator2 server两个app system_port = util.create_port(server_ip, 8200, 8299) appium_p = subprocess.Popen( "appium -a {} -p {} --relaxed-security --session-override > {} 2>&1 &" .format(server_ip, appium_port, appium_log_path), shell=True) # 命令行启动appium服务 else: raise EnvironmentError('设备平台类型传参错误:--cmd_pf='+pf) time.sleep(10) # 新测试报告 global rp_logger rp_logger = logging.getLogger(__name__) rp_logger.setLevel(logging.DEBUG) # Create handler for Report Portal if the service has been # configured and started. if hasattr(request.node.config, 'py_test_service'): # Import Report Portal logger and handler to the test module. logging.setLoggerClass(RPLogger) rp_handler = RPLogHandler(request.node.config.py_test_service) # Add additional handlers if it is necessary console_handler = logging.StreamHandler(sys.stdout) console_handler.setLevel(logging.INFO) rp_logger.addHandler(console_handler) else: rp_handler = logging.StreamHandler(sys.stdout) # Set INFO level for Report Portal handler. rp_handler.setLevel(logging.INFO) GlobalVar.set_rp_logger(rp_logger) def teardown(): try: os.killpg(os.getegid(appium_p.pid+1), signal.SiGTERM) except Exception as e: print(e) pass request.addfinalizer(teardown)
def bulbs_add_device(self, check_account, bulbs_off, reset_phone_network): """ 添加灯泡: 1. app首页点击+,选择bulbs 2. 点击Next,勾选 Status Confirmed,点击 next, 勾选 Status Confirmed,点击 next 3. 选择亚添加的设备id 4. 连接中,等待conecting消失 【checkpoint】判断是否显示添加成功(文本校验) 5. 修改设备昵称未T1013,点击保存 6. 返回设备主页查看设备列表 【checkpoint】首页列表刷新后显示灯泡1013 :param check_account: :return: """ if GlobalVar.get_remove_add() == 0: GlobalVar.set_test_flag('f') pytest.skip('本次指定不执行词条用例') home_page.swipe_page('down') if home_page.find_device(data.get_device('white_bulbs')): home_page.into_device_home_page(data.get_device('white_bulbs')) TestBulbs.bulbs_ready() bulbs_home_page.into_setting() bulbs_setting_page.swipe_page('up') bulbs_setting_page.click_remove() bulbs_setting_page.commit_remove() bulbs_setting_page.loading() home_page.click_add_device() add_device_page.click_bulds() wifi = data.get_wifi('white_bulbs') add_device_page.set_wifi(wifi[0], wifi[1]) add_device_page.confirm_bulbs_status() add_device_page.bulbs_next() add_device_page.confirm_bulbs_status() add_device_page.bulbs_next() add_device_page.select_robotic_by_id(data.get_device_udid('white_bulbs')) add_device_page.loading() add_device_page.wait_connect() assert add_device_page.connect_result(), 'bulbs 配网连接失败' add_device_page.set_device_name(data.get_device('white_bulbs')) add_device_page.ok add_device_page.loading() home_page.swipe_page('down') assert home_page.find_device(data.get_device('white_bulbs')), 'bulbs 配网成功后首页未查找到设备'
def test_switch_remove(self, check_account): """ 移除智能开关: 1. app首页点击进入设备主页,点击more进入设置界面 2. 点击remove 【checkpoint】弹出移除成功确认弹窗 【checkpoint】返回app首页,设备列表不显示switch :return: """ if GlobalVar.get_remove_add() == 0: pytest.skip('本次指定不执行词条用例') home_page.into_device_home_page(data.get_device('switch')) TestSwitch.switch_ready() switch_home_page.into_setting() switch_setting_page.click_remove() assert switch_setting_page.text_display( 'Are you sure you want to remove this device?'), 'switch 移除未显示确认弹窗' switch_setting_page.commit_remove() switch_setting_page.loading() assert home_page.is_welcome(), 'switch 移除后未返回app首页' home_page.swipe_page('down') assert home_page.find_device( data.get_device('switch')) is False, 'switch 移除后设备列表未删除设备'
def bulbs_remove(self, check_account): """ 移除灯泡球产品: 1. app首页点击进入设备主页,点击more进入设置界面 2. 点击remove 【checkpoint】弹出移除成功确认弹窗 【checkpoint】返回app首页,设备列表不显示light :param check_account: :return: """ if GlobalVar.get_remove_add() == 0: pytest.skip('本次指定不执行词条用例') home_page.into_device_home_page(data.get_device('white_bulbs')) TestBulbs.bulbs_ready() bulbs_home_page.into_setting() bulbs_setting_page.swipe_page('up') bulbs_setting_page.click_remove() assert bulbs_setting_page.text_display('Are you sure you want to remove this device?'), '未显示移除确认弹窗' bulbs_setting_page.commit_remove() bulbs_setting_page.loading() assert home_page.is_welcome(), '移除设备后未返回app首页' home_page.swipe_page('down') assert home_page.find_device(data.get_device('white_bulbs')) is False, 'bulbs 删除后首页仍然显示'
def __init__(self, driver): super().__init__(driver) if GlobalVar.get_platform() == GlobalVar.IOS: from src.eufyhome.ios.app.AllShareActivity import AllShareActivity else: from src.eufyhome.android.app.AllShareActivity import AllShareActivity global Page Page = AllShareActivity()
def switch_close_yellow_tip(self): """ 关闭小黄条提示 :return: """ yield 1 if GlobalVar.get_test_flag(): switch_schedule_page.close_yellow_tip()
def reset_phone_network(self): """ 检查并重置手机网络,防止配网失败影响网络 :return: """ yield 1 if GlobalVar.get_test_flag(): add_device_page.set_system_wifi(data.get_wifi('phone')[0])
def test_plug_add_device(self, check_account, reset_phone_network): """ 添加插座设备: 1. app首页点击+,选择plug,设置wifi 2. 勾选 Status Confirmed,点击 next 3. 选择亚添加的设备id 4. 连接中,等待conecting消失 【checkpoint】判断是否显示添加成功(文本校验) 5. 修改设备昵称未T1100,点击保存 6. 返回设备主页查看设备列表 【checkpoint】首页列表刷新后显示插座T1100 :return: """ if GlobalVar.get_remove_add() == 0: GlobalVar.set_test_flag('f') pytest.skip('本次指定不执行词条用例') home_page.swipe_page('down') if home_page.find_device(data.get_device('plugs')): home_page.into_device_home_page(data.get_device('plugs')) TestPlug.plug_ready() plug_home_page.into_setting() plug_setting_page.click_remove() plug_setting_page.commit_remove() plug_setting_page.loading() home_page.click_add_device() add_device_page.click_plug() wifi_data = data.get_wifi('plugs') add_device_page.set_wifi(wifi_data[0], wifi_data[1]) add_device_page.confirm_bulbs_status() add_device_page.bulbs_next() add_device_page.select_robotic_by_id(data.get_device_udid('plugs')) add_device_page.wait_connect() assert add_device_page.connect_result(), 'plugs 配网连接失败' add_device_page.set_device_name(data.get_device('plugs')) add_device_page.ok add_device_page.loading() home_page.swipe_page('down') assert home_page.find_device( data.get_device('plugs')), 'plugs 配网成功后首页未查找到设备'
def init_setup(self): """ 使用 @pytest.fixture(scope='function') 装饰器的方法可以看做是setup方法 scope指定级别,取值可以是"function"(default),"class","module","package" or "session" :return: """ global base_page, start_page, user_page, time_zone_page, system_page, news_page, change_pw_page, home_page, \ all_share_page, help_faq_page, share_setting_page, add_device_page, bulbs_default_light_page, device_help_page, \ bulbs_schedule_page, bulbs_group_home_page, bulbs_update_page, bulbs_home_page, bulbs_effect_page, bulbs_favorite_page,\ bulbs_setting_page, bulbs_group_page GlobalVar.set_test_flag('f') base_page = BasePage(self.driver) start_page = StartPage(self.driver) home_page = HomePage(self.driver) user_page = UserPage(self.driver) time_zone_page = TimeZonePage(self.driver) system_page = SystemPage(self.driver) news_page = NewsPage(self.driver) change_pw_page = ChangePWPage(self.driver) all_share_page = AllSharePage(self.driver) share_setting_page = ShareSettingPage(self.driver) add_device_page = AddDevicePage(self.driver) device_help_page = DeviceHelpPage(self.driver) help_faq_page = HelpFAQPage(self.driver) bulbs_home_page = BulbsHomePage(self.driver) bulbs_effect_page = BulbsEffectPage(self.driver) bulbs_favorite_page = BulbsFavoritePage(self.driver) bulbs_setting_page = BulbsSettingPage(self.driver) bulbs_group_page = BulbsGroupPage(self.driver) bulbs_default_light_page = BulbsDefaultLightPage(self.driver) bulbs_schedule_page = BulbsSchedulePage(self.driver) bulbs_group_home_page = BulbsGroupHomePage(self.driver) bulbs_update_page = BulbsUpdatePage(self.driver) # 检查ios升级弹窗 try: start_page.ignore_ios_update() except Exception as e: print('升级弹窗处理失败:\n' + e)
def close_bulbs_schedule(self): """ 关闭扫地机及定时任务 :return: """ yield 1 if GlobalVar.get_test_flag(): if bulbs_home_page.bulb_status(False): bulbs_home_page.click_bulbs() bulbs_home_page.into_schedules(False) bulbs_schedule_page.delete_schedule()
def close_switch_schedule(self): """ 关闭扫地机及定时任务 :return: """ yield 1 if GlobalVar.get_test_flag(): if switch_home_page.read_deivce_status() == 'ON': switch_home_page.click_switch_btn() switch_home_page.into_schedules() switch_schedule_page.delete_schedule()
def get_phone(self, param): """ 读取电话 :param param: :return: """ if GlobalVar.get_platform() == GlobalVar.IOS: param = param + '_ios' else: param = param + '_a' return self.cf.get('callus', param)
def set_plugs_name(self): """ 恢复设备名 :return: """ yield 1 if GlobalVar.get_test_flag(): if home_page.is_welcome(): home_page.into_device_home_page(data.get_device('plugs')) if plug_home_page.is_plug_home(): plug_home_page.into_setting() plug_setting_page.change_device_name(data.get_device('plugs')) time.sleep(1.5)
def set_switch_name(self): """ 恢复设备名 :return: """ yield 1 if GlobalVar.get_test_flag(): if home_page.is_welcome(): home_page.into_device_home_page(data.get_device('switch')) if switch_home_page.is_switch_home(): switch_home_page.into_setting() switch_setting_page.change_switch_name(data.get_device('switch')) time.sleep(1.5)
def init_setup(self): """ 使用 @pytest.fixture(scope='function') 装饰器的方法可以看做是setup方法 scope指定级别,取值可以是"function"(default),"class","module","package" or "session" :return: """ global base_page, start_page, user_page, home_page, system_page, add_device_page, genie_page GlobalVar.set_test_flag('f') base_page = BasePage(self.driver) start_page = StartPage(self.driver) home_page = HomePage(self.driver) user_page = UserPage(self.driver) system_page = SystemPage(self.driver) add_device_page = AddDevicePage(self.driver) genie_page = GeniePage(self.driver) # 检查ios升级弹窗 try: start_page.ignore_ios_update() except Exception as e: print('升级弹窗处理失败:\n' + e)
def delete_share_news(self): """ 删除被分享人消息列表的通知 :return: """ yield 1 if GlobalVar.get_test_flag(): base_page.kill_app() base_page.open_app() home_page.into_system() system_page.into_news() news_page.clear_all() news_page.yes time.sleep(2.5)
def white_bulbs_change_group_name(self, check_account): """ 修改分组名称: 1. app首页点击进入分组主页,点击设置 2. 点击分组group_***修改名称为group_随机数,点击save 【checkpoint】分组名称显示group_随机数 :param check_account: :return: """ home_page.into_group_page(data.get_bulbs_group('bulbs')) bulbs_group_home_page.into_group_setting() new_name = data.get_bulbs_group('bulbs')+bulbs_group_home_page.get_str() print(new_name) bulbs_group_home_page.change_group_name(new_name) assert bulbs_group_home_page.text_display(new_name), '分组名称修改后设置界面显示错误' GlobalVar.set_test_flag('t') bulbs_group_home_page.back_group() assert new_name in bulbs_group_home_page.read_home_group_name(), '分组名称修改后分组首页显示名称错误' bulbs_group_home_page.back_home() home_page.swipe_page('down') assert home_page.find_group(new_name), '分组名称修改后app首页显示名称错误'