class PersonalCenterPage(Base): def __init__(self, driver): self.base = Base(driver) # 点击个人中心页--我的账号图标 ---wmw def clickFlymemeB(self): # 判断页面是否存在未登录 if self.base.elementIsExit(PERSONAL_CENTER_NOT_LOGGED_IN): self.base.clickByElement(PERSONAL_CENTER_FLYME_ME_A, '我的账号图标') else: self.assertFalse(PERSONAL_CENTER_NOT_LOGGED_IN) # 点击我的消息 ---wmw def clickMyMessages(self): # 判断页面是否存在我的账号图标 if self.base.elementIsExit(PERSONAL_CENTER_FLYME_ME_A): self.base.clickByElement(PERSONAL_CENTER_MY_MESSAGES, '我的消息') else: self.assertFalse(PERSONAL_CENTER_FLYME_ME_A) # 点击我的评论 ---wmw def clickMyComment(self): # 判断页面是否存在我的账号图标 if self.base.elementIsExit(PERSONAL_CENTER_FLYME_ME_A): self.base.clickByElement(PERSONAL_CENTER_MY_COMMENT, '我的评论') else: self.assertFalse(PERSONAL_CENTER_FLYME_ME_A) # 判断账号是否登陆,未登录则登录账号 ---wmw def elementIsLandFlymeme(self): # 判断页面是否存在未登录 if self.base.elementIsExit(PERSONAL_CENTER_NOT_LOGGED_IN): self.base.clickByElement(PERSONAL_CENTER_FLYME_ME_A, '我的账号图标') # 输入密码 self.inputPassWord() # 点击登录 self.clickLoggenIn() sleep(4) # 此处有bug,为了确保当前页面账号更新已登陆成功,故多点几次我的消息 self.clickMyMessages() self.clickMyMessages() else: return # 点击赞了我的消息 ---wmw def clickPraisedMyMessages(self): if self.base.elementIsExit(PERSONAL_CENTER_MY_MESSAGES_A): self.base.clickByElement(PERSONAL_CENTER_MY_MESSAGES_A, '赞了我的消息') else: self.assertFalse(PERSONAL_CENTER_MY_MESSAGES_A) # 点击我的评论页,第一条评论 ---wmw def clickPraisedMyComment(self): if self.base.elementIsExit(PERSONAL_CENTER_MY_COMMENT_A): self.base.clickByElement(PERSONAL_CENTER_COMMENT_ONE, '点击我的评论页,第一条评论') else: self.assertFalse(PERSONAL_CENTER_MY_COMMENT_A) # 输入密码 ---wmw def inputPassWord(self): if self.base.elementIsExit(PERSONAL_CENTER_PASSWORD): # 备注:账号必须是测试账号,账号输入框处必须有账号名在里面,否则登录不成功 self.base.elementSetText(PERSONAL_CENTER_PASSWORD, "appadmin111", "输入密码") else: self.assertFalse(PERSONAL_CENTER_PASSWORD) # 登录 ---wmw def clickLoggenIn(self): if self.base.elementIsExit(PERSONAL_CENTER_REGISTER): self.base.clickByElement(PERSONAL_CENTER_LOGGED_IN, "登录") else: self.assertFalse(PERSONAL_CENTER_REGISTER) # 点击评论文章 ---wmw def clickCommentary(self): if self.base.elementIsExit(PERSONAL_CENTER_COMMENT_DETAILS): self.base.clickByElement(PERSONAL_CENTER_COMMENTARY, "点击评论文章") else: self.assertFalse(PERSONAL_CENTER_COMMENT_DETAILS) # 点击小游戏——LYX def clickMiniGame(self): if self.base.elementIsExit(MINI_GAME): self.base.clickByElement(MINI_GAME, "小游戏") else: self.assertFalse(MINI_GAME) # 点击删除评论——wmw def clickDelete(self): if self.base.elementIsExit(NEWS_INPUT_COMMENTS): self.base.clickByElement(PERSONAL_CENTER_DELETE, "点击删除") else: self.assertFalse(NEWS_INPUT_COMMENTS) # 点击删除评论弹框--确定按钮——wmw def clickDeleteBox(self): if self.base.elementIsExit(PERSONAL_CENTER_DELETE_BOX): self.base.clickByElement(PERSONAL_CENTER_DETERMINE, "点击确定") else: self.assertFalse(PERSONAL_CENTER_DELETE_BOX) # 在个人中心页,点击退出账号 ---wmw def clickOutAccount(self): # 判断页面是否存在我的账号图标 if self.base.elementIsExit(PERSONAL_CENTER_NOT_LOGGED_IN): return else: self.base.clickByElement(PERSONAL_CENTER_FLYME_ME_A, '我的账号图标') if self.base.elementIsExit(PERSONAL_CENTER_ACCOUNT): self.base.clickByElement(PERSONAL_CENTER_ACCOUNT, "点击账号管理") if self.base.elementIsExit(PERSONAL_CENTER_OUT_ACCOUNT): self.base.clickByElement(PERSONAL_CENTER_OUT_ACCOUNT, "点击退出账号") if self.base.elementIsExit(PERSONAL_CENTER_PASSWORD_B): # 备注:账号必须是测试账号,账号输入框处必须有账号名在里面,否则登录不成功 self.base.elementSetText(PERSONAL_CENTER_PASSWORD_B, "appadmin111", "输入退出密码") if self.base.elementIsExit(PERSONAL_CENTER_DETERMINE): self.base.clickByElement(PERSONAL_CENTER_DETERMINE, "点击确定") else: self.assertFalse(PERSONAL_CENTER_DETERMINE) else: self.assertFalse(PERSONAL_CENTER_PASSWORD_B) else: self.assertFalse(PERSONAL_CENTER_OUT_ACCOUNT) else: if self.base.elementIsExit(PERSONAL_CENTER_COMPLETE_BUTTON): self.base.clickByElementIdAndInstance( PERSONAL_CENTER_BUTTON, "点击同步数据按钮", 0) self.base.clickByElementIdAndInstance( PERSONAL_CENTER_BUTTON, "点击查找手机按钮", 1) self.base.clickByElement(PERSONAL_CENTER_COMPLETE_BUTTON, "点击完成按钮") if self.base.elementIsExit(PERSONAL_CENTER_ACCOUNT): self.base.clickByElement(PERSONAL_CENTER_ACCOUNT, "点击账号管理") if self.base.elementIsExit( PERSONAL_CENTER_OUT_ACCOUNT): self.base.clickByElement( PERSONAL_CENTER_OUT_ACCOUNT, "点击退出账号") if self.base.elementIsExit( PERSONAL_CENTER_PASSWORD_B): # 备注:账号必须是测试账号,账号输入框处必须有账号名在里面,否则登录不成功 self.base.elementSetText( PERSONAL_CENTER_PASSWORD_B, "appadmin111", "输入退出密码") if self.base.elementIsExit( PERSONAL_CENTER_DETERMINE): self.base.clickByElement( PERSONAL_CENTER_DETERMINE, "点击确定") else: self.assertFalse(PERSONAL_CENTER_DETERMINE) else: self.assertFalse(PERSONAL_CENTER_PASSWORD_B) else: self.assertFalse(PERSONAL_CENTER_OUT_ACCOUNT) else: self.assertFalse(PERSONAL_CENTER_COMPLETE_BUTTON) # 点击语言和时间——wmw def clickLanguageAndTime(self): if self.base.elementIsExit(SETTINGS): self.base.clickByElement(LANGUAGE_AND_TIME, "语言和时间") else: self.assertFalse(SETTINGS) # 点击系统输入法——wmw def clickInputMethod(self): if self.base.elementIsExit(LANGUAGE_AND_TIME): self.base.clickByElement(INPUT_METHOD, "系统输入法") else: self.assertFalse(LANGUAGE_AND_TIME) # 点击设置按钮——wmw def clickSettingButton(self): if self.base.elementIsExit(SETTINGS_BUTTON): self.base.clickByElement(SETTINGS_BUTTON, "设置按钮") else: self.assertFalse(SETTINGS_BUTTON) # 点击搜狗输入法魅族版——wmw def clickSouGou(self): if self.base.elementIsExit(SOUGOU): self.base.clickByElement(SOUGOU, "搜狗输入法魅族版") else: self.assertFalse(SOUGOU)
class DownPage(Base): def __init__(self, driver): self.base = Base(driver) # 长按下载网页 def longLink(self): if self.base.elementIsExit(SEARCH_PAGE_REFRASH): self.base.long_clickByElement(LONG_SEARCH_PAGR_LINK, '长按搜索结果页网页链接') else: self.assertFalse(SEARCH_PAGE_REFRASH) # 点击长按弹框中的“下载链接”按钮 def clickDownLink(self): if self.base.elementIsExit(LONG_PRESS_BOX): self.base.clickByElement(DOWNLINK, '点击长按菜单弹框中的“下载链接”按钮') else: self.assertFalse(LONG_PRESS_BOX) # 点击下载弹框中的“下载”按钮 def clickDownButton(self): if self.base.elementIsExit(DOWNLOAD_NAME): self.base.clickByElement(DOWN_LOAD, '点击下载弹框中的“下载”按钮') else: self.assertFalse(DOWNLOAD_NAME) # 点击下载弹框中的“取消”按钮 def clickCancelButton(self): if self.base.elementIsExit(DOWNLOAD_NAME): self.base.clickByElement(DOWN_CANCEL, '点击下载弹框中的“取消”按钮') else: self.assertFalse(DOWNLOAD_NAME) # 地址栏输入“QQ应用” def inputApp(self): if self.base.elementIsExit(SEARCHPANEL_ANOTHERCHANGE): self.base.elementSetText(SEARCHPANEL_WEBSITE, APPNAME, "输入“QQ”") else: self.assertFalse(SEARCHPANEL_ANOTHERCHANGE) # 地址栏输入“QQ应用” def clickAppDown(self): if self.base.elementIsExit(QQDOWN): self.base.clickByElement(QQDOWN, "点击“高速下载”") else: self.assertFalse(QQDOWN) # 获取下载弹框中的标题内容————LCM def getDownTitle(self, element): if self.base.elementIsExit(element): return self.base.elementText(element, '获取下载弹框中的标题内容') else: self.assertFalse(element) # 长按下载管理页面中的文件————LCM def longPressElement(self): if self.base.elementIsExit(DOWN_LOAD_MANAGE_TITLE): if self.base.elementIsExit(DOWN_LOAD_MANAGE_TITLE): self.base.long_clickByElement(DOWN_LOAD_MANAGE_TITLE, '长按下载管理页面中的文件') else: self.assertFalse(DOWN_LOAD_MANAGE_TITLE) else: self.base.usePhone('back') # 点击操作下载管理页面中的文件————LCM def clickChoose(self): # 判断“全选”按钮存在,则点击全选 if self.base.elementIsExit(DOWN_LOAD_MANAGE_CHOOSE): self.base.clickByElement(DOWN_LOAD_MANAGE_CHOOSE, '选择下载管理页面中的文件') self.clickDeleteAllFile() # 判断“全不选”按钮存在,则点击“删除” elif self.base.elementIsExit(DOWN_LOAD_MANAGE_CHOOSEONE): self.clickDeleteAllFile() else: self.assertFalse(DOWN_LOAD_MANAGE_CHOOSE) # 下载管理页面中点击删除按钮————LCM def clickDeleteAllFile(self): if self.base.elementIsExit(DOWN_LOAD_MANAGE_RENAME): # 点击删除按钮 self.base.clickByElement(DOWN_LOAD_MANAGE_DELETE_SELECTED, '点击删除按钮') self.clickDelete() else: self.assertFalse(DOWN_LOAD_MANAGE_RENAME) # 下载管理页面中点击删除所有的文件————LCM def clickDelete(self): if self.base.elementIsExit(DOWN_LOAD_MANAGE_DELETE): # 点击删除全部文件 self.base.clickByElement(DOWN_LOAD_MANAGE_DELETE, '点击删除下载管理页面中的文件') else: self.assertFalse(DOWN_LOAD_MANAGE_DELETE_SELECTED)
class SearchPanelPage(Base): def __init__(self, driver): self.base = Base(driver) # 点击搜索历史热词(默认点击第一个) ---wmw def clickSearchHistory(self): if self.base.elementIsExit(SEARCHPANEL_SEARCHHISTORY): self.base.clickByElement(SEARCHPANEL_SEARCHHISTORY, "搜索历史热词") sleep(2) else: self.assertFalse(SEARCHPANEL_SEARCHHISTORY) # 点击换一换 ---wmw def clickAnotherChange(self): if self.base.elementIsExit(SEARCHPANEL_ANOTHERCHANGE): self.base.clickByElement(SEARCHPANEL_ANOTHERCHANGE, "换一换") else: self.assertFalse(SEARCHPANEL_ANOTHERCHANGE) # 点击输入框工具条前缀词“www.”——LYX def clickInputPanelPrefixes(self): if self.base.elementIsExit(INPUTPANEL_PROMPT): self.base.clickByElement(INPUTPANEL_PROMPT, "输入框前缀词www.") else: self.assertFalse(INPUTPANEL_PROMPT) # 长按地址栏中的“www.”——LYX def long_clickSearchPanel(self): if self.base.elementIsExit(SEARCHPANEL_WEBSITE): self.base.long_clickByElement(SEARCHPANEL_WEBSITE, "地址栏文字www") else: self.assertFalse(SEARCHPANEL_WEBSITE) # 拖动输入框中的工具条——LYX def swipe_InputPanel(self): if self.base.elementIsExit(INPUTPANEL_SWIPE): self.base.swipeByElement(INPUTPANEL_SWIPE, "向左拖动工具条", "left", 200) else: self.assertFalse(INPUTPANEL_SWIPE) # 获取第一个搜索热词 ---wmw def clickHotWords(self): if self.base.elementIsExit(SEARCHPANEL_SEARCH): return self.base.elementText(SEARCHPANEL_HOTWORDS, "第一个搜索热词") else: self.assertFalse(SEARCHPANEL_SEARCH) # 点击清空 ---wmw def clickEmpty(self): if self.base.elementIsExit(SEARCHPANEL_EMPTY): self.base.clickByElement(SEARCHPANEL_EMPTY, "清空") else: self.assertFalse(SEARCHPANEL_EMPTY) # 点击搜索框——LYX def clickSearchPanel(self): if self.base.elementIsExit(SEARCHPANEL_WEBSITE): self.base.clickByElement(SEARCHPANEL_WEBSITE, "搜索框") else: self.assertFalse(SEARCHPANEL_WEBSITE) # 点击搜索框联想词——LYX def clickAutomatedWord(self): if self.base.elementIsExit(AUTOMATED_WORD): self.base.clickByElement(AUTOMATED_WORD, "搜索框联想词") else: self.assertFalse(AUTOMATED_WORD) # 点击地址栏清空按钮——LYX def clearSearchPanel(self): if self.base.elementIsExit(SEARCHPANEL_CLEAR): self.base.clickByElement(SEARCHPANEL_CLEAR, "地址栏清空按钮") else: self.assertFalse(SEARCHPANEL_CLEAR) # 点击清空搜索历史——LYX def clearSearchHistory(self): if self.base.elementIsExit(CLEARSEARCHHISTORY): self.base.clickByElement(CLEARSEARCHHISTORY, "地址栏清空按钮") else: self.assertFalse(CLEARSEARCHHISTORY) # 地址栏输入百度——LYX def inputBaidu(self): if self.base.elementIsExit(SEARCHPANEL_WEBSITE): self.base.elementSetText(SEARCHPANEL_WEBSITE, "m.baidu.com", "百度网址") else: self.assertFalse(SEARCHPANEL_WEBSITE) # 点击搜索框右侧的搜索/进入按钮——LYX def clickSearchInto(self): if self.base.elementIsExit(SEARCHPANEL_OPEN): self.base.clickByElement(SEARCHPANEL_OPEN, "搜索框右侧进入按钮") else: self.assertFalse(SEARCHPANEL_OPEN) # 搜索框输入m.80txt.com --wmw def inputNumber(self): if self.base.elementIsExit(SEARCHPANEL_TEXT): self.base.elementSetText(SEARCHPANEL_TEXT, "m.80txt.la", "搜索框输入m.80txt.com") else: self.assertFalse(SEARCHPANEL_TEXT) # 滑动百度页面——LYX def swipeBaidu(self): if self.base.elementIsExit(BAIDU_LOGO): self.base.swipeByElement(BAIDU_LOGO, '滑动百度页面', 'up') else: self.assertFalse(BAIDU_LOGO) # 点击百度页面收起的地址栏——LYX def clickwebsite(self): if self.base.elementIsExit(WEBSITE_PACKUP): self.base.clickByElement(WEBSITE_PACKUP, "百度页面收起的地址栏") else: self.assertFalse(WEBSITE_PACKUP) # 长按搜索历史中的百度网址——LYX def long_clickSearchHistory(self): if self.base.elementIsExit(BAIDU_WEBSITE): self.base.long_clickByElement(BAIDU_WEBSITE, "搜索历史中的百度网址") else: self.assertFalse(BAIDU_WEBSITE) # 点击搜索历史中的删除按钮——LYX def delete_SearchHistory(self): if self.base.elementIsExit(DELETESEARCHHISTORY): self.base.clickByElement(DELETESEARCHHISTORY, "搜索历史中的删除按钮") else: self.base.assertFalse(DELETESEARCHHISTORY) # 地址栏输入主题美化跳转地址——LYX def inputCustomize(self): if self.base.elementIsExit(SEARCHPANEL_WEBSITE): self.base.elementSetText(SEARCHPANEL_WEBSITE, CUSTOMIZE_ADDRESS, "百度网址") else: self.assertFalse(SEARCHPANEL_WEBSITE) # 点击主题美化跳转提示,允许按钮——LYX def skipCustomize(self): if self.base.elementIsExit(CUSTOMIZE_SKIP, 2): self.base.clickByElement(CUSTOMIZE_SKIP, "允许跳转至主题美化") else: self.base.assertFalse(CUSTOMIZE_SKIP) # 获取搜索框文本 ---wmw def clickSearchText(self): if self.base.elementIsExit(SEARCHPANEL_OPEN): return self.base.elementText(SEARCHPANEL_TEXT, "获取搜索框文本") else: self.base.assertFalse(CUSTOMIZE_SKIP) # 点击某个元素多次 —— LJX def clickMoreRefresh(self, element, times): if self.base.elementIsExit(element): for i in range(1, times): self.base.clickByElement(element, '第{}次点击{}按钮'.format(i, element)) else: self.base.assertFalse(element)
class SetUpPage(Base): def __init__(self, driver): self.base = Base(driver) # 点击魅族头条设置 ---wmw def clickMeizuHeadlinesSettings(self): if self.base.elementIsExit(SETUP_ID): self.base.clickByElement(MEIZU_HEAD, "魅族头条设置") else: self.assertFalse(SETUP_ID) # 点击简版显示 ---wmw def clickSimple(self): if self.base.elementIsExit(SETUP_SIMPLE): self.base.clickByElement(SETUP_SIMPLE, "简版显示") else: self.assertFalse(SETUP_SIMPLE) # 点击简版显示--更多 ---wmw def clickSetUpMore(self): if self.base.elementIsExit(SETUP_MORE): self.base.clickByElement(SETUP_MORE, "简版显示--更多") else: self.assertFalse(SETUP_MORE) # 点击清除浏览数据 ---wmw def clickClearCoolkies(self): if self.base.elementIsExit(CLEAR_DATA): self.base.clickByElement(CLEAR_DATA, "清除浏览数据") else: self.assertFalse(CLEAR_DATA) # 点击清除浏览数据--Cookies ---wmw def clickCookies(self): if self.base.elementIsExit(SETUP_COOKIES): self.base.clickByElement(SETUP_COOKIES, "Cookies") else: self.assertFalse(SETUP_COOKIES) # 点击清除浏览数据--账号密码 ---wmw def clickAccountsAndPasswords(self): if self.base.elementIsExit(SETUP_ACCOUNTS_AND_PASSWORDS): self.base.clickByElement(SETUP_ACCOUNTS_AND_PASSWORDS, "账号密码") else: self.assertFalse(SETUP_ACCOUNTS_AND_PASSWORDS) # 点击清除浏览数据--地理位置授权 ---wmw def clickLocationAccess(self): if self.base.elementIsExit(SETUP_LOCATION_ACCESS): self.base.clickByElement(SETUP_LOCATION_ACCESS, "地理位置授权") else: self.assertFalse(SETUP_LOCATION_ACCESS) # 点击清除浏览数据按钮 ---wmw def clickClearData(self): if self.base.elementIsExit(SETUP_CLEAR_DATA): self.base.clickByElement(SETUP_CLEAR_DATA, "清除数据按钮") else: self.assertFalse(SETUP_CLEAR_DATA) # 点击完成按钮 ---wmw def clickDone(self): if self.base.elementIsExit(SETUP_DONE): self.base.clickByElement(SETUP_DONE, "完成按钮") else: self.assertFalse(SETUP_DONE) # 点击搜索引擎 ---wmw def clickSearchEngine(self): if self.base.elementIsExit(SEARCH_ENGINE): self.base.clickByElement(SEARCH_ENGINE, "搜索引擎") else: self.assertFalse(SEARCH_ENGINE) # 点击百度 --wmw def clickBaidu(self): if self.base.elementIsExit(SETUP_BAIDU): self.base.clickByElement(SETUP_BAIDU, "百度") else: self.assertFalse(SETUP_BAIDU) #搜索框输入123 --wmw def inputNumber(self): if self.base.elementIsExit(SEARCHPANEL_TEXT): self.base.elementSetText(SEARCHPANEL_TEXT, "123", "搜索框输入123") else: self.assertFalse(SEARCHPANEL_TEXT) # 搜索框输入百度 --wmw def inputbaidu(self): if self.base.elementIsExit(SEARCHPANEL_TEXT): self.base.elementSetText(SEARCHPANEL_TEXT, 'www.baidu.com', "搜索框输入百度") else: self.assertFalse(SEARCHPANEL_TEXT) # 点击广告屏蔽 ---wmw def clickBlockAds(self, element): if self.base.elementIsExit(element): if self.obtainBlockAdsSwitch(element) == "关闭": return else: self.base.clickByElementRight(element, SETUP_SWITCH, direction='right') else: self.assertFalse(element) # 点击恢复默认设置 ---wmw def clickResetToDefault(self): if self.base.elementIsExit(SETUP_RESET_TEXT): self.base.clickByElement(SETUP_RESET_TEXT, "恢复默认设置") else: self.assertFalse(SETUP_RESET_TEXT) # 点击恢复默认设置---恢复 --wmw def clickReset(self): if self.base.elementIsExit(SETUP_RESET): self.base.clickByElement(SETUP_RESET, "恢复") else: self.assertFalse(SETUP_RESET) # # 获取广告屏蔽开关状态 ---wmw # def obtainBlockAdsSwitch(self): # if self.base.elementIsExit(SETUP_ID): # return self.base.elementText(SETUP_SWITCH, "开关状态",0) # else: # self.assertFalse(SETUP_ID) # 获取广告屏蔽开关状态 ---wmw def obtainBlockAdsSwitch(self, element): if self.base.elementIsExit(SETUP_ID): return self.base.ObtianRightelementText(element, SETUP_SWITCH, direction='right') else: self.assertFalse(SETUP_ID) # 获取精选内容推送开关状态 ---wmw def obtainSwipeLeftRightSwitch(self, element): if self.base.elementIsExit(SETUP_ID): return self.base.ObtianRightelementText(element, SETUP_SWITCH, direction='right') else: self.assertFalse(SETUP_ID) # # 获取精选内容推送开关状态 ---wmw # def obtainSwipeLeftRightSwitch(self): # if self.base.elementIsExit(SETUP_ID): # return self.base.elementText(SETUP_SWITCH, "开关状态",3) # else: # self.assertFalse(SETUP_ID) # 点击精选内容推送 ---wmw def clickSwipeLeftRight(self, element): if self.base.elementIsExit(element): if self.obtainSwipeLeftRightSwitch(element) == "关闭": return else: self.base.clickByElementRight(element, SETUP_SWITCH, direction='right') else: self.assertFalse(element) # 点击允许 ---wmw def clickAllow(self): if self.base.elementIsExit(SETUP_ALLOW): self.base.clickByElement(SETUP_ALLOW, "允许") else: self.assertFalse(SETUP_ALLOW) # 点击360 ————LCM def click360(self): if self.base.elementIsExit(SETUP_360): self.base.clickByElement(SETUP_360, "360") else: self.assertFalse(SETUP_360)