def __init__(self): '''初始化''' self.yamltool = ReadYamlTools('LoginPage.yaml') self.xmltool = ReadXmlTools() self.driver = WebdriverTools() self.ele_loc = self.yamltool.get_yaml_all_items('LoginPage') self.datas = self.xmltool.get_childs_items('LoginPage')
def __init__(self): '''初始化''' self.yamltool = ReadYamlTools('GameListPage.yaml') self.xmltool = ReadXmlTools() self.log = LogTools() self.driver = WebdriverTools() self.GL_eleloc = self.yamltool.get_yaml_section_items( 'GameListPage', 'GL') self.JJFS_eleloc = self.yamltool.get_yaml_section_items( 'GameListPage', 'JJFS') self.BZRM_eleloc = self.yamltool.get_yaml_section_items( 'GameListPage', 'BZRM') self.datas = self.xmltool.get_childs_items('GameListPage')
def __init__(self): '''初始化''' self.yamltool = ReadYamlTools('FaXianPage.yaml') self.xmltool = ReadXmlTools() self.log = LogTools() self.driver = WebdriverTools() self.FX_eleloc = self.yamltool.get_yaml_section_items( 'FaXianPage', 'FX') self.FJJY_eleloc = self.yamltool.get_yaml_section_items( 'FaXianPage', 'FJJY') self.PSPH_eleloc = self.yamltool.get_yaml_section_items( 'FaXianPage', 'PSPH') self.PSJB_eleloc = self.yamltool.get_yaml_section_items( 'FaXianPage', 'PSJB') self.datas = self.xmltool.get_childs_items('FaXianPage')
def __init__(self): '''初始化''' self.yamltool = ReadYamlTools('TuiJianPage.yaml') self.xmltool = ReadXmlTools() self.log = LogTools() self.driver = WebdriverTools() self.TJ_eleloc = self.yamltool.get_yaml_section_items( 'TuiJianPage', 'TJ') self.ESJY_eleloc = self.yamltool.get_yaml_section_items( 'TuiJianPage', 'ESJY') self.FEGM_eleloc = self.yamltool.get_yaml_section_items( 'TuiJianPage', 'FEGM') self.GMFS_eleloc = self.yamltool.get_yaml_section_items( 'TuiJianPage', 'GMFS') self.GMPL_eleloc = self.yamltool.get_yaml_section_items( 'TuiJianPage', 'GMPL') self.datas = self.xmltool.get_childs_items('TuiJianPage')
def __init__(self): '''初始化''' self.yamltool = ReadYamlTools('LunTanPage.yaml') self.xmltool = ReadXmlTools() self.log = LogTools() self.driver = WebdriverTools() self.LT_eleloc = self.yamltool.get_yaml_section_items( 'LunTanPage', 'LT') self.ZHHF_eleloc = self.yamltool.get_yaml_section_items( 'LunTanPage', 'ZHHF') self.ZXFB_eleloc = self.yamltool.get_yaml_section_items( 'LunTanPage', 'ZXFB') self.JHT_eleloc = self.yamltool.get_yaml_section_items( 'LunTanPage', 'JHT') self.ZDT_eleloc = self.yamltool.get_yaml_section_items( 'LunTanPage', 'ZDT') self.datas = self.xmltool.get_childs_items('LunTanPage')
class TuiJianPageClass: def __init__(self): '''初始化''' self.yamltool = ReadYamlTools('TuiJianPage.yaml') self.xmltool = ReadXmlTools() self.log = LogTools() self.driver = WebdriverTools() self.TJ_eleloc = self.yamltool.get_yaml_section_items( 'TuiJianPage', 'TJ') self.ESJY_eleloc = self.yamltool.get_yaml_section_items( 'TuiJianPage', 'ESJY') self.FEGM_eleloc = self.yamltool.get_yaml_section_items( 'TuiJianPage', 'FEGM') self.GMFS_eleloc = self.yamltool.get_yaml_section_items( 'TuiJianPage', 'GMFS') self.GMPL_eleloc = self.yamltool.get_yaml_section_items( 'TuiJianPage', 'GMPL') self.datas = self.xmltool.get_childs_items('TuiJianPage') def action_goto_esjy(self): '''二手交易专区--二手交易--二手交易评论''' self.log.info('[action_start]二手交易评论操作执行开始') try: #进入二手交易专区 self.driver.wait_for_one_of_eles( self.TJ_eleloc['element_ershoudeal'], 1, 10) self.driver.one_of_elements_click( self.TJ_eleloc['element_ershoudeal'], 1) self.driver.wait_for_element( self.ESJY_eleloc['element_esjy_title'], 5) self.log.info('[action]进入二手交易专区成功') #进入二手相关交易 self.driver.one_of_elements_click( self.ESJY_eleloc['elements_esjy_deal'], 0) self.driver.wait_for_element( self.ESJY_eleloc['element_deal_gameattr'], 5) self.log.info('[action]选择的二手交易成功') #二手交易评论 self.driver.element_click(self.ESJY_eleloc['element_deal_pl']) self.driver.wait_for_element( self.ESJY_eleloc['element_deal_pl_input'], 5) self.log.info('[action]进入二手交易评论模块成功') self.driver.element_click( self.ESJY_eleloc['element_deal_pl_input']) self.driver.element_sendkeys( self.ESJY_eleloc['element_deal_pl_input'], self.datas['esjy_pl']) time.sleep(2) self.driver.element_click(self.ESJY_eleloc['element_deal_pl_ok']) self.driver.wait_for_element( self.ESJY_eleloc['element_deal_gameattr'], 5) self.log.info('[action]二手交易评论成功,评论内容为【{}】'.format( self.datas['esjy_pl'])) self.log.info('[action]即将返回主页') #返回主页 self.driver.element_click(self.ESJY_eleloc['element_deal_goback']) time.sleep(2) self.driver.wait_for_element( self.ESJY_eleloc['element_esjy_title'], 5) self.driver.element_click(self.ESJY_eleloc['element_esjy_goback']) time.sleep(2) self.driver.wait_for_element(self.TJ_eleloc['element_tj_title'], 5) self.log.info('[action]返回主页成功') self.log.info('[action_result]二手交易评论操作执行成功') self.log.info('[action_end]二手交易评论操作执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]二手交易评论操作执行失败') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('二手交易评论失败') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_goto_freegame(self): '''PS+会员免费游戏评论''' self.log.info('[action_start]PS+会员免费游戏评论操作执行开始') try: #进入PS+会员免费游戏新闻 self.driver.wait_for_one_of_eles( self.TJ_eleloc['element_freegame'], 2, 10) self.driver.one_of_elements_click( self.TJ_eleloc['element_freegame'], 2) self.driver.wait_for_element(self.FEGM_eleloc['element_gamenews'], 5) self.log.info('[action]进入PS+会员免费游戏新闻成功') #点击评论模块 self.driver.element_click(self.FEGM_eleloc['element_gamenews_pl']) self.driver.wait_for_element(self.FEGM_eleloc['element_pl_title'], 5) self.log.info('[action]进入评论模块成功') #发表评论 self.driver.element_click(self.FEGM_eleloc['element_pl_door']) self.driver.wait_for_element(self.FEGM_eleloc['element_pl_input'], 5) self.log.info('[action]即将发表评论') self.driver.element_click(self.FEGM_eleloc['element_pl_input']) self.driver.element_sendkeys(self.FEGM_eleloc['element_pl_input'], self.datas['fegm_pl']) self.driver.element_click(self.FEGM_eleloc['element_pl_ok']) self.driver.wait_for_one_of_eles( self.FEGM_eleloc['element_pl_text'], 0, 5) self.log.info('[action]评论成功,评论内容为{}'.format(self.datas['fegm_pl'])) self.log.info('[action]即将返回主页') #返回主页 self.driver.element_click(self.FEGM_eleloc['element_pl_goback']) self.driver.wait_for_element( self.FEGM_eleloc['element_gamenews_pl'], 5) self.driver.element_click( self.FEGM_eleloc['element_gamenews_goback']) self.driver.wait_for_element(self.TJ_eleloc['element_tj_title'], 5) self.log.info('[action_result]PS+会员免费游戏评论操作执行成功') self.log.info('[aciton_end]PS+会员免费游戏评论操作执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]PS+会员免费游戏评论操作执行失败') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('PS+会员免费游戏评论失败') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_goto_gamelist(self): '''游戏发售表分享并取消''' self.log.info('[action_start]游戏发售表操作执行开始') try: #进入游戏发售表 self.driver.wait_for_one_of_eles( self.TJ_eleloc['element_gamelist'], 3, 10) self.driver.one_of_elements_click( self.TJ_eleloc['element_gamelist'], 3) self.driver.wait_for_element( self.GMFS_eleloc['element_gmfs_title'], 5) self.log.info('[action]进入游戏发售表成功') #游戏发售表分享并取消 self.driver.wait_for_element(self.GMFS_eleloc['element_gmfs_fx'], 5) self.driver.element_click(self.GMFS_eleloc['element_gmfs_fx']) self.driver.wait_for_element(self.GMFS_eleloc['element_fx_cancle'], 5) self.log.info('[action]发售表分享打开成功') self.driver.element_click(self.GMFS_eleloc['element_fx_cancle']) self.driver.wait_for_element( self.GMFS_eleloc['element_gmfs_title'], 5) self.log.info('[action]发售表分享并取消') #返回主页 self.log.info('[action]即将返回主页') self.driver.element_click(self.GMFS_eleloc['element_gmfs_goback']) self.driver.wait_for_element(self.TJ_eleloc['element_tj_title'], 5) self.log.info('[action_result]游戏发售表操作执行成功') self.log.info('[aciton_end]游戏发售表操作执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]游戏发售表操作执行失败') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('游戏发售表操作失败') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_goto_gamenews(self): '''游戏新闻发表评论''' self.log.info('[action_start]游戏新闻发表评论操作执行开始') try: # 进入游戏新闻 self.driver.wait_for_one_of_eles( self.GMPL_eleloc['elements_newslist'], 1, 10) self.driver.one_of_elements_click( self.GMPL_eleloc['elements_newslist'], 1) self.driver.wait_for_element(self.GMPL_eleloc['element_news_pl'], 5) self.log.info('[action]进入游戏新闻成功') #点击评论 self.driver.element_click(self.GMPL_eleloc['element_news_pl']) self.driver.wait_for_element(self.GMPL_eleloc['element_pl_input'], 5) self.log.info('[aciton]开始发表评论') #编辑评论并发送 self.driver.element_click(self.GMPL_eleloc['element_pl_input']) self.driver.element_sendkeys(self.GMPL_eleloc['element_pl_input'], self.datas['gmpl_pl']) self.driver.element_click(self.GMPL_eleloc['element_pl_ok']) self.driver.wait_for_element(self.GMPL_eleloc['element_news_pl'], 5) self.log.info('[action]评论发表成功,评论内容为【{}】'.format( self.datas['gmpl_pl'])) self.log.info('[action]即将返回主页') #返回主页 self.driver.element_click(self.GMPL_eleloc['element_news_goback']) self.driver.wait_for_element(self.TJ_eleloc['element_tj_title'], 5) self.log.info('[action_result]游戏新闻发表评论操作执行成功') self.log.info('[aciton_end]游戏新闻发表评论操作执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]游戏新闻发表评论操作执行失败') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('游戏新闻发表评论失败') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def quitDriver(self): self.driver.quitDriver()
class LoginAction: def __init__(self): '''初始化''' self.yamltool = ReadYamlTools('LoginPage.yaml') self.xmltool = ReadXmlTools() self.driver = WebdriverTools() self.ele_loc = self.yamltool.get_yaml_all_items('LoginPage') self.datas = self.xmltool.get_childs_items('LoginPage') def action_checklogin(self): '''判断登录app时用户是否登录: 第一种情况:检查【我的】界面,若已经登录,则返回到首页 第二种情况:检查【我的】界面,若没有登录,则直接进行登录,登录后返回首页 ''' self.driver.wait_for_element(self.ele_loc['element_wode'], 10) self.driver.element_click(self.ele_loc['element_wode']) time.sleep(5) #用户没有登录则进行登录操作 try: self.driver.wait_for_element(self.ele_loc['element_nologin'], 10) self.driver.element_click(self.ele_loc['element_nologin']) self.driver.wait_for_element(self.ele_loc['element_login_button'], 10) #输入账号 self.driver.element_click(self.ele_loc['element_username']) self.driver.element_clear(self.ele_loc['element_username']) self.driver.element_sendkeys(self.ele_loc['element_username'], self.datas['login_username']) #输入密码 self.driver.element_click(self.ele_loc['element_pwd']) self.driver.element_sendkeys(self.ele_loc['element_pwd'], self.datas['login_pwd']) #点击登录按钮 self.driver.element_click(self.ele_loc['element_login_button']) #验证是否登录成功 self.driver.wait_for_element(self.ele_loc['element_logout'], 10) print('[action_result]用户登录成功') #用户已经登录则返回推荐页面 except: self.driver.wait_for_element(self.ele_loc['element_logout'], 10) self.driver.element_click(self.ele_loc['element_tuijian']) self.driver.wait_for_element(self.ele_loc['element_tuijian_title'], 10) print('[action_result]用户已经登录,无需登录,已跳转推荐页面')
class LunTanPageClass: def __init__(self): '''初始化''' self.yamltool = ReadYamlTools('LunTanPage.yaml') self.xmltool = ReadXmlTools() self.log = LogTools() self.driver = WebdriverTools() self.LT_eleloc = self.yamltool.get_yaml_section_items( 'LunTanPage', 'LT') self.ZHHF_eleloc = self.yamltool.get_yaml_section_items( 'LunTanPage', 'ZHHF') self.ZXFB_eleloc = self.yamltool.get_yaml_section_items( 'LunTanPage', 'ZXFB') self.JHT_eleloc = self.yamltool.get_yaml_section_items( 'LunTanPage', 'JHT') self.ZDT_eleloc = self.yamltool.get_yaml_section_items( 'LunTanPage', 'ZDT') self.datas = self.xmltool.get_childs_items('LunTanPage') def action_pl_zhhf(self): '''论坛模块-最后回复帖子评论''' self.log.info('[action_start]论坛模块最后回复帖子评论操作执行开始') try: #进入论坛模块 self.driver.wait_for_element(self.LT_eleloc['element_lt'], 10) self.driver.element_click(self.LT_eleloc['element_lt']) self.driver.wait_for_element(self.LT_eleloc['element_lt_title'], 10) self.log.info('[action]进入论坛模块成功') #进入Switch综合讨论专区 self.driver.wait_for_element(self.LT_eleloc['element_ns_lt'], 10) self.driver.element_click(self.LT_eleloc['element_ns_lt']) self.driver.wait_for_element(self.LT_eleloc['element_ns_lt_title'], 10) self.log.info('[action]进入Switch综合讨论专区成功') #进入最后回复模块 self.driver.element_click(self.LT_eleloc['element_ns_zhhf']) self.driver.wait_for_one_of_eles( self.ZHHF_eleloc['elements_zhhf_list'], 2, 10) self.driver.one_of_elements_click( self.ZHHF_eleloc['elements_zhhf_list'], 2) self.driver.wait_for_element(self.ZHHF_eleloc['element_zhhf_dxck'], 10) self.log.info('[action]进入最后回复模块帖子成功') #发表评论 self.driver.wait_for_element(self.ZHHF_eleloc['element_zhhf_fbhf'], 10) self.driver.element_click(self.ZHHF_eleloc['element_zhhf_fbhf']) self.driver.wait_for_element(self.ZHHF_eleloc['element_zhhf_hf'], 10) self.driver.element_click(self.ZHHF_eleloc['element_zhhf_hf']) self.driver.element_sendkeys(self.ZHHF_eleloc['element_zhhf_hf'], self.datas['zhhf_pl']) self.driver.element_click(self.ZHHF_eleloc['element_zhhf_hf_ok']) self.driver.wait_for_element(self.ZHHF_eleloc['element_zhhf_zklz'], 10) self.log.info('[action]最后回复模块帖子评论成功,评论内容为【{}】'.format( self.datas['zhhf_pl'])) self.log.info('[action]即将返回论坛') #返回论坛 self.driver.element_click(self.ZHHF_eleloc['element_zhhf_goback']) self.driver.wait_for_element(self.LT_eleloc['element_ns_lt_title'], 10) self.driver.element_click(self.LT_eleloc['element_ns_goback']) self.driver.wait_for_element(self.LT_eleloc['element_lt_title'], 10) self.log.info('[action]返回论坛成功') self.log.info('[action_result]论坛模块最后回复帖子评论执行成功') self.log.info('[action_end]论坛模块最后回复帖子评论执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]论坛模块最后回复帖子评论执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('论坛最后回复帖子评论执行') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_pl_zxfb(self): '''论坛模块-最新发布帖子评论''' self.log.info('[action_start]论坛模块最新发布帖子评论操作执行开始') try: #进入论坛模块 self.driver.wait_for_element(self.LT_eleloc['element_lt'], 10) self.driver.element_click(self.LT_eleloc['element_lt']) self.driver.wait_for_element(self.LT_eleloc['element_lt_title'], 10) self.log.info('[action]进入论坛模块成功') #进入Switch综合讨论专区 self.driver.wait_for_element(self.LT_eleloc['element_ns_lt'], 10) self.driver.element_click(self.LT_eleloc['element_ns_lt']) self.driver.wait_for_element(self.LT_eleloc['element_ns_lt_title'], 10) self.log.info('[action]进入Switch综合讨论专区成功') #进入最新发布模块 self.driver.element_click(self.LT_eleloc['element_ns_zxfb']) self.driver.wait_for_one_of_eles( self.ZXFB_eleloc['elements_zxfb_list'], 2, 10) self.driver.one_of_elements_click( self.ZXFB_eleloc['elements_zxfb_list'], 2) self.driver.wait_for_element(self.ZXFB_eleloc['element_zxfb_dxck'], 10) self.log.info('[action]进入最新发布模块帖子成功') #发表评论 self.driver.wait_for_element(self.ZXFB_eleloc['element_zxfb_fbhf'], 10) self.driver.element_click(self.ZXFB_eleloc['element_zxfb_fbhf']) self.driver.wait_for_element(self.ZXFB_eleloc['element_zxfb_hf'], 10) self.driver.element_click(self.ZXFB_eleloc['element_zxfb_hf']) self.driver.element_sendkeys(self.ZXFB_eleloc['element_zxfb_hf'], self.datas['zxfb_pl']) self.driver.element_click(self.ZXFB_eleloc['element_zxfb_hf_ok']) self.driver.wait_for_element(self.ZXFB_eleloc['element_zxfb_zklz'], 10) self.log.info('[action]最新发布模块帖子评论成功,评论内容为【{}】'.format( self.datas['zxfb_pl'])) self.log.info('[action]即将返回论坛') #返回论坛 self.driver.element_click(self.ZXFB_eleloc['element_zxfb_goback']) self.driver.wait_for_element(self.LT_eleloc['element_ns_lt_title'], 10) self.driver.element_click(self.LT_eleloc['element_ns_goback']) self.driver.wait_for_element(self.LT_eleloc['element_lt_title'], 10) self.log.info('[action]返回论坛成功') self.log.info('[action_result]论坛模块最新发布帖子评论执行成功') self.log.info('[action_end]论坛模块最新发布帖子评论执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]论坛模块最新发布帖子评论执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('论坛最新发布帖子评论执行') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_pl_jht(self): '''论坛模块-精华帖帖子评论''' self.log.info('[action_start]论坛模块精华帖帖子评论操作执行开始') try: #进入论坛模块 self.driver.wait_for_element(self.LT_eleloc['element_lt'], 10) self.driver.element_click(self.LT_eleloc['element_lt']) self.driver.wait_for_element(self.LT_eleloc['element_lt_title'], 10) self.log.info('[action]进入论坛模块成功') #进入Switch综合讨论专区 self.driver.wait_for_element(self.LT_eleloc['element_ns_lt'], 10) self.driver.element_click(self.LT_eleloc['element_ns_lt']) self.driver.wait_for_element(self.LT_eleloc['element_ns_lt_title'], 10) self.log.info('[action]进入Switch综合讨论专区成功') #进入精华帖模块 self.driver.element_click(self.LT_eleloc['element_ns_jht']) self.driver.wait_for_one_of_eles( self.JHT_eleloc['elements_jht_list'], 1, 10) self.driver.one_of_elements_click( self.JHT_eleloc['elements_jht_list'], 1) self.driver.wait_for_element(self.JHT_eleloc['element_jht_dxck'], 10) self.log.info('[action]进入精华帖模块帖子成功') #发表评论 self.driver.wait_for_element(self.JHT_eleloc['element_jht_fbhf'], 10) self.driver.element_click(self.JHT_eleloc['element_jht_fbhf']) self.driver.wait_for_element(self.JHT_eleloc['element_jht_hf'], 10) self.driver.element_click(self.JHT_eleloc['element_jht_hf']) self.driver.element_sendkeys(self.JHT_eleloc['element_jht_hf'], self.datas['jht_pl']) self.driver.element_click(self.JHT_eleloc['element_jht_hf_ok']) self.driver.wait_for_element(self.JHT_eleloc['element_jht_zklz'], 10) self.log.info('[action]精华帖模块帖子评论成功,评论内容为【{}】'.format( self.datas['jht_pl'])) self.log.info('[action]即将返回论坛') #返回论坛 self.driver.element_click(self.JHT_eleloc['element_jht_goback']) self.driver.wait_for_element(self.LT_eleloc['element_ns_lt_title'], 10) self.driver.element_click(self.LT_eleloc['element_ns_goback']) self.driver.wait_for_element(self.LT_eleloc['element_lt_title'], 10) self.log.info('[action]返回论坛成功') self.log.info('[action_result]论坛模块精华帖帖子评论执行成功') self.log.info('[action_end]论坛模块精华帖帖子评论执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]论坛模块精华帖帖子评论执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('论坛精华帖帖子评论执行') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_pl_zdt(self): '''论坛模块-置顶帖帖子评论''' self.log.info('[action_start]论坛模块置顶帖帖子评论操作执行开始') try: #进入论坛模块 self.driver.wait_for_element(self.LT_eleloc['element_lt'], 10) self.driver.element_click(self.LT_eleloc['element_lt']) self.driver.wait_for_element(self.LT_eleloc['element_lt_title'], 10) self.log.info('[action]进入论坛模块成功') #进入Switch综合讨论专区 self.driver.wait_for_element(self.LT_eleloc['element_ns_lt'], 10) self.driver.element_click(self.LT_eleloc['element_ns_lt']) self.driver.wait_for_element(self.LT_eleloc['element_ns_lt_title'], 10) self.log.info('[action]进入Switch综合讨论专区成功') #进入置顶帖模块 self.driver.element_click(self.LT_eleloc['element_ns_zdt']) self.driver.wait_for_one_of_eles( self.ZDT_eleloc['elements_zdt_list'], 5, 10) self.driver.one_of_elements_click( self.ZDT_eleloc['elements_zdt_list'], 5) self.driver.wait_for_element(self.ZDT_eleloc['element_zdt_dxck'], 10) self.log.info('[action]进入置顶帖模块帖子成功') #发表评论 self.driver.wait_for_element(self.ZDT_eleloc['element_zdt_fbhf'], 10) self.driver.element_click(self.ZDT_eleloc['element_zdt_fbhf']) self.driver.wait_for_element(self.ZDT_eleloc['element_zdt_hf'], 10) self.driver.element_click(self.ZDT_eleloc['element_zdt_hf']) self.driver.element_sendkeys(self.ZDT_eleloc['element_zdt_hf'], self.datas['zdt_pl']) self.driver.element_click(self.ZDT_eleloc['element_zdt_hf_ok']) self.driver.wait_for_element(self.ZDT_eleloc['element_zdt_zklz'], 10) self.log.info('[action]置顶帖模块帖子评论成功,评论内容为【{}】'.format( self.datas['zdt_pl'])) self.log.info('[action]即将返回论坛') #返回论坛 self.driver.element_click(self.ZDT_eleloc['element_jht_goback']) self.driver.wait_for_element(self.LT_eleloc['element_ns_lt_title'], 10) self.driver.element_click(self.LT_eleloc['element_ns_goback']) self.driver.wait_for_element(self.LT_eleloc['element_lt_title'], 10) self.log.info('[action]返回论坛成功') self.log.info('[action_result]论坛模块置顶帖子评论执行成功') self.log.info('[action_end]论坛模块置顶帖子评论执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]论坛模块置顶帖子评论执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('论坛置顶帖子评论执行') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def quitDriver(self): self.driver.quitDriver()
class FaXianPageClass: def __init__(self): '''初始化''' self.yamltool = ReadYamlTools('FaXianPage.yaml') self.xmltool = ReadXmlTools() self.log = LogTools() self.driver = WebdriverTools() self.FX_eleloc = self.yamltool.get_yaml_section_items( 'FaXianPage', 'FX') self.FJJY_eleloc = self.yamltool.get_yaml_section_items( 'FaXianPage', 'FJJY') self.PSPH_eleloc = self.yamltool.get_yaml_section_items( 'FaXianPage', 'PSPH') self.PSJB_eleloc = self.yamltool.get_yaml_section_items( 'FaXianPage', 'PSJB') self.datas = self.xmltool.get_childs_items('FaXianPage') def action_add_fjjy(self): '''发现模块-添加附近机友''' self.log.info('[action_start]发现模块添加附近机友操作流程执行开始') try: #进入发现模块 self.driver.wait_for_element(self.FX_eleloc['element_fx'], 10) self.driver.element_click(self.FX_eleloc['element_fx']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]发现模块进入成功') #进入找机友 self.driver.wait_for_element(self.FX_eleloc['element_fx_jy'], 10) self.driver.element_click(self.FX_eleloc['element_fx_jy']) self.driver.wait_for_element( self.FJJY_eleloc['element_fjjy_title'], 10) self.log.info('[action]找机友模块进入成功') #添加机友 self.driver.wait_for_element(self.FJJY_eleloc['element_fjjy_fjjy'], 10) self.driver.element_click(self.FJJY_eleloc['element_fjjy_fjjy']) time.sleep(2) self.driver.one_of_elements_click( self.FJJY_eleloc['elements_fjjy_jy_list'], 2) self.driver.wait_for_element( self.FJJY_eleloc['element_fjjy_jy_title'], 10) self.driver.wait_for_element( self.FJJY_eleloc['element_fjjy_jy_add'], 10) self.driver.element_click(self.FJJY_eleloc['element_fjjy_jy_add']) self.driver.wait_for_element( self.FJJY_eleloc['element_fjjy_jy_add_input'], 10) self.driver.element_click( self.FJJY_eleloc['element_fjjy_jy_add_input']) self.driver.element_sendkeys( self.FJJY_eleloc['element_fjjy_jy_add_input'], self.datas['FJJY_pl']) self.driver.element_click( self.FJJY_eleloc['element_fjjy_jy_add_ok']) self.driver.wait_for_element( self.FJJY_eleloc['element_fjjy_jy_title'], 10) self.log.info('[action]添加机友请求发送成功,添加机友内容为【{}】'.format( self.datas['FJJY_pl'])) self.log.info('[action]即将返回发现模块') #返回发现模块 self.driver.element_click( self.FJJY_eleloc['element_fjjy_jy_goback']) self.driver.wait_for_element( self.FJJY_eleloc['element_fjjy_title'], 10) self.driver.element_click(self.FJJY_eleloc['element_fjjy_goback']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]返回发现模块成功') self.log.info('[action_result]发现模块添加附近机友操作流程执行成功') self.log.info('[action_end]发现模块添加附近机友操作流程执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]发现模块添加附近机友操作流程执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('发现模块添加附近机友') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_psjb_sj(self): '''发现模块-PS奖杯时间分类-评论''' self.log.info('[action_start]发现模块PS奖杯时间分类评论流程操作执行开始') try: # 进入发现模块 self.driver.wait_for_element(self.FX_eleloc['element_fx'], 10) self.driver.element_click(self.FX_eleloc['element_fx']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]发现模块进入成功') #进入ps奖杯 self.driver.wait_for_element(self.FX_eleloc['element_fx_yxjb'], 10) self.driver.element_click(self.FX_eleloc['element_fx_yxjb']) self.driver.wait_for_element(self.PSJB_eleloc['element_jb_title'], 10) self.log.info('[action]PSN游戏奖杯模块进入成功') #进入时间ps奖杯 self.driver.wait_for_element(self.PSJB_eleloc['element_jb_sj'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_sj']) self.driver.wait_for_one_of_eles( self.PSJB_eleloc['elements_jb_gm_list'], 0, 10) self.driver.one_of_elements_click( self.PSJB_eleloc['elements_jb_gm_list'], 0) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jblist_title'], 10) self.log.info('[action]PSN游戏奖杯模块时间分类模块游戏奖杯进入成功') #选择一个奖杯进行评论 self.driver.one_of_elements_click( self.PSJB_eleloc['elements_jb_gm_jblist'], 1) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jbxq'], 10) self.log.info('[action]游戏奖杯详情进入成功') self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_fbpl'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_gm_fbpl']) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_fbpl_input'], 10) self.driver.element_click( self.PSJB_eleloc['element_jb_gm_fbpl_input']) self.driver.element_sendkeys( self.PSJB_eleloc['element_jb_gm_fbpl_input'], self.datas['PSJB_sj_pl']) self.driver.element_click( self.PSJB_eleloc['element_jb_gm_fbpl_ok']) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jbxq'], 10) self.log.info('[action]奖杯评论成功,评论内容为【{}】'.format( self.datas['PSJB_sj_pl'])) self.log.info('[action]即将返回发现模块') #返回发现模块 self.driver.element_click( self.PSJB_eleloc['element_jb_gm_jbxq_goback']) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jblist_title'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_gm_goback']) self.driver.wait_for_element(self.PSJB_eleloc['element_jb_title'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_goback']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]返回发现模块成功') self.log.info('[action_result]发现模块PS奖杯时间分类评论流程执行成功') self.log.info('[action_end]发现模块PS奖杯时间分类评论流程执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]发现模块PS奖杯时间分类评论流程执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('发现模块PS奖杯时间分类评论') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_psjb_fs(self): '''发现模块-PS奖杯分数分类-评论''' self.log.info('[action_start]发现模块PS奖杯分数分类评论流程操作执行开始') try: # 进入发现模块 self.driver.wait_for_element(self.FX_eleloc['element_fx'], 10) self.driver.element_click(self.FX_eleloc['element_fx']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]发现模块进入成功') #进入ps奖杯 self.driver.wait_for_element(self.FX_eleloc['element_fx_yxjb'], 10) self.driver.element_click(self.FX_eleloc['element_fx_yxjb']) self.driver.wait_for_element(self.PSJB_eleloc['element_jb_title'], 10) self.log.info('[action]PSN游戏奖杯模块进入成功') #进入时间ps奖杯 self.driver.wait_for_element(self.PSJB_eleloc['element_jb_fs'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_fs']) self.driver.wait_for_one_of_eles( self.PSJB_eleloc['elements_jb_gm_list'], 0, 10) self.driver.one_of_elements_click( self.PSJB_eleloc['elements_jb_gm_list'], 0) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jblist_title'], 10) self.log.info('[action]PSN游戏奖杯模块分数分类模块游戏奖杯进入成功') #选择一个奖杯进行评论 self.driver.one_of_elements_click( self.PSJB_eleloc['elements_jb_gm_jblist'], 1) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jbxq'], 10) self.log.info('[action]游戏奖杯详情进入成功') self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_fbpl'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_gm_fbpl']) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_fbpl_input'], 10) self.driver.element_click( self.PSJB_eleloc['element_jb_gm_fbpl_input']) self.driver.element_sendkeys( self.PSJB_eleloc['element_jb_gm_fbpl_input'], self.datas['PSJB_fs_pl']) self.driver.element_click( self.PSJB_eleloc['element_jb_gm_fbpl_ok']) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jbxq'], 10) self.log.info('[action]奖杯评论成功,评论内容为【{}】'.format( self.datas['PSJB_fs_pl'])) self.log.info('[action]即将返回发现模块') #返回发现模块 self.driver.element_click( self.PSJB_eleloc['element_jb_gm_jbxq_goback']) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jblist_title'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_gm_goback']) self.driver.wait_for_element(self.PSJB_eleloc['element_jb_title'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_goback']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]返回发现模块成功') self.log.info('[action_result]发现模块PS奖杯分数分类评论流程执行成功') self.log.info('[action_end]发现模块PS奖杯分数分类评论流程执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]发现模块PS奖杯分数分类评论流程执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('发现模块PS奖杯分数分类评论') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_psjb_wjs(self): '''发现模块-PS奖杯玩家数分类-评论''' self.log.info('[action_start]发现模块PS奖杯玩家数分类评论流程操作执行开始') try: # 进入发现模块 self.driver.wait_for_element(self.FX_eleloc['element_fx'], 10) self.driver.element_click(self.FX_eleloc['element_fx']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]发现模块进入成功') #进入ps奖杯 self.driver.wait_for_element(self.FX_eleloc['element_fx_yxjb'], 10) self.driver.element_click(self.FX_eleloc['element_fx_yxjb']) self.driver.wait_for_element(self.PSJB_eleloc['element_jb_title'], 10) self.log.info('[action]PSN游戏奖杯模块进入成功') #进入时间ps奖杯 self.driver.wait_for_element(self.PSJB_eleloc['element_jb_wjs'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_wjs']) self.driver.wait_for_one_of_eles( self.PSJB_eleloc['elements_jb_gm_list'], 0, 10) self.driver.one_of_elements_click( self.PSJB_eleloc['elements_jb_gm_list'], 0) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jblist_title'], 10) self.log.info('[action]PSN游戏奖杯模块玩家数分类模块游戏奖杯进入成功') #选择一个奖杯进行评论 self.driver.one_of_elements_click( self.PSJB_eleloc['elements_jb_gm_jblist'], 1) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jbxq'], 10) self.log.info('[action]游戏奖杯详情进入成功') self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_fbpl'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_gm_fbpl']) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_fbpl_input'], 10) self.driver.element_click( self.PSJB_eleloc['element_jb_gm_fbpl_input']) self.driver.element_sendkeys( self.PSJB_eleloc['element_jb_gm_fbpl_input'], self.datas['PSJB_wjs_pl']) self.driver.element_click( self.PSJB_eleloc['element_jb_gm_fbpl_ok']) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jbxq'], 10) self.log.info('[action]奖杯评论成功,评论内容为【{}】'.format( self.datas['PSJB_wjs_pl'])) self.log.info('[action]即将返回发现模块') #返回发现模块 self.driver.element_click( self.PSJB_eleloc['element_jb_gm_jbxq_goback']) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jblist_title'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_gm_goback']) self.driver.wait_for_element(self.PSJB_eleloc['element_jb_title'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_goback']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]返回发现模块成功') self.log.info('[action_result]发现模块PS奖杯玩家数分类评论流程执行成功') self.log.info('[action_end]发现模块PS奖杯玩家数分类评论流程执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]发现模块PS奖杯玩家数分类评论流程执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('发现模块PS奖杯玩家数分类评论') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_psjb_nd(self): '''发现模块-PS奖杯难度分类-评论''' self.log.info('[action_start]发现模块PS奖杯难度分类评论流程操作执行开始') try: # 进入发现模块 self.driver.wait_for_element(self.FX_eleloc['element_fx'], 10) self.driver.element_click(self.FX_eleloc['element_fx']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]发现模块进入成功') #进入ps奖杯 self.driver.wait_for_element(self.FX_eleloc['element_fx_yxjb'], 10) self.driver.element_click(self.FX_eleloc['element_fx_yxjb']) self.driver.wait_for_element(self.PSJB_eleloc['element_jb_title'], 10) self.log.info('[action]PSN游戏奖杯模块进入成功') #进入时间ps奖杯 self.driver.wait_for_element(self.PSJB_eleloc['element_jb_nd'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_nd']) self.driver.wait_for_one_of_eles( self.PSJB_eleloc['elements_jb_gm_list'], 0, 10) self.driver.one_of_elements_click( self.PSJB_eleloc['elements_jb_gm_list'], 0) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jblist_title'], 10) self.log.info('[action]PSN游戏奖杯模块难度分类模块游戏奖杯进入成功') #选择一个奖杯进行评论 self.driver.one_of_elements_click( self.PSJB_eleloc['elements_jb_gm_jblist'], 1) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jbxq'], 10) self.log.info('[action]游戏奖杯详情进入成功') self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_fbpl'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_gm_fbpl']) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_fbpl_input'], 10) self.driver.element_click( self.PSJB_eleloc['element_jb_gm_fbpl_input']) self.driver.element_sendkeys( self.PSJB_eleloc['element_jb_gm_fbpl_input'], self.datas['PSJB_nd_pl']) self.driver.element_click( self.PSJB_eleloc['element_jb_gm_fbpl_ok']) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jbxq'], 10) self.log.info('[action]奖杯评论成功,评论内容为【{}】'.format( self.datas['PSJB_nd_pl'])) self.log.info('[action]即将返回发现模块') #返回发现模块 self.driver.element_click( self.PSJB_eleloc['element_jb_gm_jbxq_goback']) self.driver.wait_for_element( self.PSJB_eleloc['element_jb_gm_jblist_title'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_gm_goback']) self.driver.wait_for_element(self.PSJB_eleloc['element_jb_title'], 10) self.driver.element_click(self.PSJB_eleloc['element_jb_goback']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]返回发现模块成功') self.log.info('[action_result]发现模块PS奖杯难度分类评论流程执行成功') self.log.info('[action_end]发现模块PS奖杯难度分类评论流程执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]发现模块PS奖杯难度分类评论流程执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('发现模块PS奖杯难度分类评论') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_psph_dj(self): '''发现模块-PS排行榜-通过等级查看玩家信息''' self.log.info('[action_start]发现模块PS排行榜等级分类查看玩家信息流程操作执行开始') try: # 进入发现模块 self.driver.wait_for_element(self.FX_eleloc['element_fx'], 10) self.driver.element_click(self.FX_eleloc['element_fx']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]发现模块进入成功') # 进入ps排行榜 self.driver.wait_for_element(self.FX_eleloc['element_fx_ph'], 10) self.driver.element_click(self.FX_eleloc['element_fx_ph']) self.driver.wait_for_element(self.PSPH_eleloc['element_ph_title'], 10) self.log.info('[action]PS排行榜模块进入成功') #进入等级-玩家信息界面 self.driver.wait_for_element(self.PSPH_eleloc['element_ph_dj'], 10) self.driver.element_click(self.PSPH_eleloc['element_ph_dj']) self.driver.wait_for_one_of_eles( self.PSPH_eleloc['elements_ph_list'], 0, 10) self.driver.one_of_elements_click( self.PSPH_eleloc['elements_ph_list'], 0) self.driver.wait_for_element( self.PSPH_eleloc['element_ph_wj_card'], 10) time.sleep(8) self.log.info('[action]进入排行榜玩家信息界面成功') self.log.info('[action]即将返回发现模块') #返回发现模块 self.driver.element_click(self.PSPH_eleloc['element_ph_wj_goback']) self.driver.wait_for_element(self.PSPH_eleloc['element_ph_title'], 10) self.driver.element_click(self.PSPH_eleloc['element_ph_goback']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]返回发现模块成功') self.log.info('[action_result]发现模块PS排行榜等级分类查看玩家信息流程操作执行成功') self.log.info('[action_end]发现模块PS排行榜等级分类查看玩家信息流程操作执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]发现模块PS排行榜等级分类查看玩家信息流程操作执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('发现模块PS排行榜等级分类查看玩家信息') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_psph_jbs(self): '''发现模块-PS排行榜-通过奖杯数查看玩家信息''' self.log.info('[action_start]发现模块PS排行榜奖杯数分类查看玩家信息流程操作执行开始') try: # 进入发现模块 self.driver.wait_for_element(self.FX_eleloc['element_fx'], 10) self.driver.element_click(self.FX_eleloc['element_fx']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]发现模块进入成功') # 进入ps排行榜 self.driver.wait_for_element(self.FX_eleloc['element_fx_ph'], 10) self.driver.element_click(self.FX_eleloc['element_fx_ph']) self.driver.wait_for_element(self.PSPH_eleloc['element_ph_title'], 10) self.log.info('[action]PS排行榜模块进入成功') #进入奖杯数-玩家信息界面 self.driver.wait_for_element(self.PSPH_eleloc['element_ph_jbs'], 10) self.driver.element_click(self.PSPH_eleloc['element_ph_jbs']) self.driver.wait_for_one_of_eles( self.PSPH_eleloc['elements_ph_list'], 0, 10) self.driver.one_of_elements_click( self.PSPH_eleloc['elements_ph_list'], 0) self.driver.wait_for_element( self.PSPH_eleloc['element_ph_wj_card'], 10) time.sleep(8) self.log.info('[action]进入排行榜玩家信息界面成功') self.log.info('[action]即将返回发现模块') #返回发现模块 self.driver.element_click(self.PSPH_eleloc['element_ph_wj_goback']) self.driver.wait_for_element(self.PSPH_eleloc['element_ph_title'], 10) self.driver.element_click(self.PSPH_eleloc['element_ph_goback']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]返回发现模块成功') self.log.info('[action_result]发现模块PS排行榜奖杯数分类查看玩家信息流程操作执行成功') self.log.info('[action_end]发现模块PS排行榜奖杯数分类查看玩家信息流程操作执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]发现模块PS排行榜奖杯数分类查看玩家信息流程操作执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('发现模块PS排行榜奖杯数分类查看玩家信息') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_psph_yxs(self): '''发现模块-PS排行榜-通过游戏数查看玩家信息''' self.log.info('[action_start]发现模块PS排行榜游戏数分类查看玩家信息流程操作执行开始') try: # 进入发现模块 self.driver.wait_for_element(self.FX_eleloc['element_fx'], 10) self.driver.element_click(self.FX_eleloc['element_fx']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]发现模块进入成功') # 进入ps排行榜 self.driver.wait_for_element(self.FX_eleloc['element_fx_ph'], 10) self.driver.element_click(self.FX_eleloc['element_fx_ph']) self.driver.wait_for_element(self.PSPH_eleloc['element_ph_title'], 10) self.log.info('[action]PS排行榜模块进入成功') #进入游戏数-玩家信息界面 self.driver.wait_for_element(self.PSPH_eleloc['element_ph_yxs'], 10) self.driver.element_click(self.PSPH_eleloc['element_ph_yxs']) self.driver.wait_for_one_of_eles( self.PSPH_eleloc['elements_ph_list'], 0, 10) self.driver.one_of_elements_click( self.PSPH_eleloc['elements_ph_list'], 0) self.driver.wait_for_element( self.PSPH_eleloc['element_ph_wj_card'], 10) time.sleep(8) self.log.info('[action]进入排行榜玩家信息界面成功') self.log.info('[action]即将返回发现模块') #返回发现模块 self.driver.element_click(self.PSPH_eleloc['element_ph_wj_goback']) self.driver.wait_for_element(self.PSPH_eleloc['element_ph_title'], 10) self.driver.element_click(self.PSPH_eleloc['element_ph_goback']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]返回发现模块成功') self.log.info('[action_result]发现模块PS排行榜游戏数分类查看玩家信息流程操作执行成功') self.log.info('[action_end]发现模块PS排行榜游戏数分类查看玩家信息流程操作执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]发现模块PS排行榜游戏数分类查看玩家信息流程操作执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('发现模块PS排行榜游戏数分类查看玩家信息') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_psph_wms(self): '''发现模块-PS排行榜-通过完美数查看玩家信息''' self.log.info('[action_start]发现模块PS排行榜完美数分类查看玩家信息流程操作执行开始') try: # 进入发现模块 self.driver.wait_for_element(self.FX_eleloc['element_fx'], 10) self.driver.element_click(self.FX_eleloc['element_fx']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]发现模块进入成功') # 进入ps排行榜 self.driver.wait_for_element(self.FX_eleloc['element_fx_ph'], 10) self.driver.element_click(self.FX_eleloc['element_fx_ph']) self.driver.wait_for_element(self.PSPH_eleloc['element_ph_title'], 10) self.log.info('[action]PS排行榜模块进入成功') #进入完美数-玩家信息界面 self.driver.wait_for_element(self.PSPH_eleloc['element_ph_wms'], 10) self.driver.element_click(self.PSPH_eleloc['element_ph_wms']) self.driver.wait_for_one_of_eles( self.PSPH_eleloc['elements_ph_list'], 0, 10) self.driver.one_of_elements_click( self.PSPH_eleloc['elements_ph_list'], 0) self.driver.wait_for_element( self.PSPH_eleloc['element_ph_wj_card'], 10) time.sleep(8) self.log.info('[action]进入排行榜玩家信息界面成功') self.log.info('[action]即将返回发现模块') #返回发现模块 self.driver.element_click(self.PSPH_eleloc['element_ph_wj_goback']) self.driver.wait_for_element(self.PSPH_eleloc['element_ph_title'], 10) self.driver.element_click(self.PSPH_eleloc['element_ph_goback']) self.driver.wait_for_element(self.FX_eleloc['element_fx_title'], 10) self.log.info('[action]返回发现模块成功') self.log.info('[action_result]发现模块PS排行榜完美数分类查看玩家信息流程操作执行成功') self.log.info('[action_end]发现模块PS排行榜完美数分类查看玩家信息流程操作执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]发现模块PS排行榜完美数分类查看玩家信息流程操作执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('发现模块PS排行榜完美数分类查看玩家信息') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def quitDriver(self): self.driver.quitDriver()
class GameListPageClass: def __init__(self): '''初始化''' self.yamltool = ReadYamlTools('GameListPage.yaml') self.xmltool = ReadXmlTools() self.log = LogTools() self.driver = WebdriverTools() self.GL_eleloc = self.yamltool.get_yaml_section_items( 'GameListPage', 'GL') self.JJFS_eleloc = self.yamltool.get_yaml_section_items( 'GameListPage', 'JJFS') self.BZRM_eleloc = self.yamltool.get_yaml_section_items( 'GameListPage', 'BZRM') self.datas = self.xmltool.get_childs_items('GameListPage') def action_jjfs(self): '''游戏库-即将发售相关操作''' self.log.info('[action_start]游戏库即将发售相关操作执行开始') try: #进入游戏库 self.driver.wait_for_element(self.GL_eleloc['element_gl'], 10) self.driver.element_click(self.GL_eleloc['element_gl']) self.driver.wait_for_element(self.GL_eleloc['element_gl_title'], 10) self.log.info('[action]进入游戏库成功') #进入即将发售游戏信息 self.driver.wait_for_one_of_eles( self.GL_eleloc['elements_gl_jjfs_list'], 6, 10) self.driver.one_of_elements_click( self.GL_eleloc['elements_gl_jjfs_list'], 6) self.driver.wait_for_element( self.JJFS_eleloc['element_jjfs_gm_title'], 10) self.log.info('[action]进入即将发售游戏信息成功') self.driver.element_click(self.JJFS_eleloc['element_jjfs_gm_sc']) time.sleep(2) self.driver.element_click(self.JJFS_eleloc['element_jjfs_gm_xxkz']) time.sleep(5) self.driver.element_click(self.JJFS_eleloc['element_jjfs_gm_xskz']) #游戏评论 self.driver.element_click(self.JJFS_eleloc['element_jjfs_gm_pl']) self.driver.wait_for_element( self.JJFS_eleloc['element_jjfs_pl_title'], 10) self.driver.wait_for_element( self.JJFS_eleloc['element_jjfs_pl_dp'], 10) self.driver.element_click(self.JJFS_eleloc['element_jjfs_pl_dp']) self.driver.wait_for_element( self.JJFS_eleloc['element_jjfs_dp_title'], 10) self.log.info('[action]进入即将发售游戏写点评界面成功') self.driver.wait_for_element( self.JJFS_eleloc['element_jjfs_dp_xw'], 10) self.driver.element_click(self.JJFS_eleloc['element_jjfs_dp_xw']) time.sleep(2) self.driver.wait_for_element( self.JJFS_eleloc['element_jjfs_dp_pt_ps4'], 10) self.driver.element_click( self.JJFS_eleloc['element_jjfs_dp_pt_ps4']) time.sleep(2) self.driver.wait_for_element( self.JJFS_eleloc['element_jjfs_dp_input'], 10) self.driver.element_click( self.JJFS_eleloc['element_jjfs_dp_input']) self.driver.element_sendkeys( self.JJFS_eleloc['element_jjfs_dp_input'], self.datas['jjfs_pl']) time.sleep(2) self.driver.element_click(self.JJFS_eleloc['element_jjfs_dp_fbpl']) self.driver.wait_for_element( self.JJFS_eleloc['element_jjfs_gm_title'], 10) self.log.info('[action]即将发售游戏评论成功,内容为{}'.format( self.datas['jjfs_pl'])) self.log.info('[action]即将返回游戏库') #返回游戏库 self.driver.wait_for_element( self.JJFS_eleloc['element_jjfs_gm_goback'], 10) self.driver.element_click( self.JJFS_eleloc['element_jjfs_gm_goback']) self.driver.wait_for_element( self.JJFS_eleloc['element_jjfs_gm_title'], 10) self.driver.element_click( self.JJFS_eleloc['element_jjfs_gm_goback']) self.driver.wait_for_element(self.GL_eleloc['element_gl_title'], 10) self.log.info('[action]返回游戏库成功') self.log.info('[action_result]游戏库即将发售相关操作执行成功') self.log.info('[action_end]游戏库即将发售相关操作执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]游戏库即将发售相关操作执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('游戏库即将发售操作执行') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def action_bzrm(self): '''游戏库-本周热门相关操作''' self.log.info('[action_start]游戏库本周热门相关操作执行开始') try: # 进入游戏库 self.driver.wait_for_element(self.GL_eleloc['element_gl'], 20) self.driver.element_click(self.GL_eleloc['element_gl']) self.driver.wait_for_element(self.GL_eleloc['element_gl_title'], 10) self.log.info('[action]进入游戏库成功') #进入本周热门游戏 self.driver.wait_for_one_of_eles( self.GL_eleloc['elements_gl_bzrm_list'], 0, 10) self.driver.one_of_elements_click( self.GL_eleloc['elements_gl_bzrm_list'], 0) self.driver.wait_for_element( self.BZRM_eleloc['element_bzrm_gm_title'], 10) self.log.info('[action]进入本周热门游戏信息成功') self.driver.element_click(self.BZRM_eleloc['element_bzrm_gm_sc']) time.sleep(3) self.driver.element_click(self.BZRM_eleloc['element_bzrm_gm_xxkz']) time.sleep(3) self.driver.element_click(self.BZRM_eleloc['element_bzrm_gm_xskz']) #游戏评论 self.driver.element_click(self.BZRM_eleloc['element_bzrm_gm_pl']) self.driver.wait_for_element( self.BZRM_eleloc['element_bzrm_pl_title'], 10) self.driver.wait_for_element( self.BZRM_eleloc['element_bzrm_pl_dp'], 10) self.driver.element_click(self.BZRM_eleloc['element_bzrm_pl_dp']) self.driver.wait_for_element( self.BZRM_eleloc['element_bzrm_dp_title'], 10) self.log.info('[action]进入本周热门游戏写点评界面成功') self.driver.element_click(self.BZRM_eleloc['element_bzrm_dp_xw']) time.sleep(2) self.driver.element_click( self.BZRM_eleloc['element_bzrm_dp_pt_ps4']) time.sleep(2) self.driver.element_click( self.BZRM_eleloc['element_bzrm_dp_input']) self.driver.element_sendkeys( self.BZRM_eleloc['element_bzrm_dp_input'], self.datas['bzrm_pl']) self.driver.element_click(self.BZRM_eleloc['element_bzrm_dp_fbpl']) self.driver.wait_for_element( self.BZRM_eleloc['element_bzrm_gm_title'], 10) self.log.info('[action]本周热门游戏评论成功,内容为{}'.format( self.datas['bzrm_pl'])) self.log.info('[action]即将返回游戏库') # 返回游戏库 self.driver.wait_for_element( self.BZRM_eleloc['element_bzrm_gm_goback'], 10) self.driver.element_click( self.BZRM_eleloc['element_bzrm_gm_goback']) self.driver.wait_for_element(self.GL_eleloc['element_gl_jjfs'], 10) self.log.info('[action]返回游戏库成功') self.log.info('[action_result]游戏库本周热门相关操作执行成功') self.log.info('[action_end]游戏库本周热门相关操作执行结束') self.log.info( '---------------------------------------------------------') except Exception as e: self.log.error('[action_error]游戏库本周热门相关操作执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('游戏库本周热门操作执行') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info( '---------------------------------------------------------') raise def quitDriver(self): self.driver.quitDriver()
class LoginPageClass: def __init__(self): '''初始化''' self.yamltool=ReadYamlTools('LoginPage.yaml') self.xmltool=ReadXmlTools() self.log=LogTools() self.driver=WebdriverTools() self.eleloc=self.yamltool.get_yaml_all_items('LoginPage') self.datas=self.xmltool.get_childs_items('LoginPage') def action_first_login(self): '''登录操作:首次登录''' self.log.info('[action_start]首次登录操作执行开始') try: self.log.info('[action_desc]首次登录') self.log.info('[action]进入app介绍页面') #app介绍页面 self.driver.wait_for_element(self.eleloc['element_page1'],10) for i in range(2): self.driver.swipe_action(630,600,90,600,1000) time.sleep(1) self.driver.wait_for_element(self.eleloc['element_tips'],3) self.driver.element_click(self.eleloc['element_tips']) self.driver.wait_for_element(self.eleloc['element_wode'],5) self.log.info('[action]点击进入成功') #app用户登录 self.log.info('[action]进入【我的】模块') self.driver.element_click(self.eleloc['element_wode']) self.driver.wait_for_element(self.eleloc['element_nologin'],5) self.driver.element_click(self.eleloc['element_nologin']) self.driver.wait_for_element(self.eleloc['element_login_button'],5) self.log.info('[action]进入【登录】界面') #登录界面输入账号 self.driver.element_click(self.eleloc['element_username']) self.driver.element_clear(self.eleloc['element_username']) self.driver.element_sendkeys(self.eleloc['element_username'],self.datas['login_username']) #登录界面输入密码 self.driver.element_click(self.eleloc['element_pwd']) self.driver.element_clear(self.eleloc['element_pwd']) self.driver.element_sendkeys(self.eleloc['element_pwd'],self.datas['login_pwd']) self.driver.element_click(self.eleloc['element_login_button']) self.driver.wait_for_element(self.eleloc['element_logout'],15) time.sleep(15) self.log.info('[action_result]用户登录成功,登录信息如下:') self.log.info('[action_result]登录用户名为{}'.format(self.datas['login_username'])) self.log.info('[action_result]登录密码为{}'.format(self.datas['login_pwd'])) self.log.info('[action_result]首次登录执行成功') self.log.info('[action_end]首次登录操作执行结束') self.log.info('---------------------------------------------------------') except Exception as e: self.log.error('[action_error]首次登录操作执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('首次登录操作失败') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info('---------------------------------------------------------') raise def action_login(self): '''登录操作:一般登录''' try: self.log.info('[action_start]一般登录操作执行开始') self.log.info('[action_desc]一般登录') self.driver.wait_for_element(self.eleloc['element_wode'],5) time.sleep(1) self.driver.element_click(self.eleloc['element_wode']) # app用户登录 self.log.info('[action]进入【我的】模块') self.driver.wait_for_element(self.eleloc['element_nologin'], 5) time.sleep(1) self.driver.element_click(self.eleloc['element_nologin']) self.driver.wait_for_element(self.eleloc['element_login_button'], 5) self.log.info('[action]进入【登录】界面') # 登录界面输入账号 self.driver.element_click(self.eleloc['element_username']) self.driver.element_clear(self.eleloc['element_username']) self.driver.element_sendkeys(self.eleloc['element_username'], self.datas['login_username']) # 登录界面输入密码 self.driver.element_click(self.eleloc['element_pwd']) self.driver.element_clear(self.eleloc['element_pwd']) self.driver.element_sendkeys(self.eleloc['element_pwd'], self.datas['login_pwd']) self.driver.element_click(self.eleloc['element_login_button']) self.driver.wait_for_element(self.eleloc['element_logout'], 15) time.sleep(15) self.log.info('[action_result]用户登录成功,登录信息如下:') self.log.info('[action_result]登录用户名为{}'.format(self.datas['login_username'])) self.log.info('[action_result]登录密码为{}'.format(self.datas['login_pwd'])) self.log.info('[action_result]一般登录操作执行成功') self.log.info('[action_end]一般登录操作执行结束') self.log.info('---------------------------------------------------------') except Exception as e: self.log.error('[action_error]一般登录操作执行失败.') self.log.error('[action_error]错误原因为{}'.format(e)) self.driver.get_screenshot_image('一般登录操作失败') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info('---------------------------------------------------------') raise def action_logout(self): '''注销操作:注销退出''' self.log.info('[action_start]注销退出操作执行开始') try: self.driver.wait_for_element(self.eleloc['element_wode'],10) self.driver.element_click(self.eleloc['element_wode']) #判断是否已经登录,登录则进行注销退出,未登录则不进行操作 self.log.info('[action]进入【我的】模块') self.driver.wait_for_element(self.eleloc['element_logout'],10) self.log.info('[action]账户已经登录,开始注销退出操作') self.driver.element_click(self.eleloc['element_logout']) self.driver.wait_for_element(self.eleloc['element_logout_tips'],3) self.driver.element_click(self.eleloc['element_logout_ok']) self.driver.wait_for_element(self.eleloc['element_nologin'],3) self.log.info('[action_result]账户注销退出成功') self.log.info('[action_end]注销退出操作执行结束') self.log.info('---------------------------------------------------------') except Exception as e: self.log.error('[Error]注销操作执行失败') self.log.error('[Error]失败原因为{}'.format(e)) self.driver.get_screenshot_image('注销退出操作失败') self.log.info('[get_image]失败场景已截图,请于{}进行查看'.format(image_path)) self.log.info('---------------------------------------------------------') raise def action_goback_shouye(self): '''强制回退到主页''' self.driver.wait_for_element(self.eleloc['element_tuijian'],100) self.driver.element_click(self.eleloc['element_tuijian']) self.driver.wait_for_element(self.eleloc['element_tuijian_title'],100) time.sleep(5) def quitDriver(self): self.driver.quitDriver()