def home_tab1(self, choiceNum): # 进入对应页面 self.elements1[choiceNum].click() time.sleep(3) # 随机下滑页面 swipe_num = random.randint(1, 20) for x in range(1, swipe_num + 1): Swipe_op.SwipeDown(self) # 随机点击页面中的漫画内容跳转 self.element_list = self.driver.find_element_by_id('android:id/list') elements_list = self.element_list.find_elements_by_id( 'com.xmtj.mkz:id/name') click_num1 = random.randint(0, len(elements_list) - 1) self.comic_name1 = elements_list[click_num1].text elements_list[click_num1].click() # 判断是否进入漫画详情页,且漫画名称与之对应 WebDriverWait(self.driver, 20).until(lambda driver: driver.find_element_by_id( 'com.xmtj.mkz:id/top_bg_layout')) element_comic = self.driver.find_element_by_id( 'com.xmtj.mkz:id/top_bg_layout') self.comic_name2 = element_comic.find_element_by_id( Page_config.PageID.comic_name).text self.assertTrue(self.comic_name1, self.comic_name2)
def home_module(self, ModuleID, titleText, GridID, gridNum): # 查找页面中的版块标题区域,测试点击返回流程 while True: try: self.driver.find_element_by_id(ModuleID).click() break except Exception, e: Swipe_op.SwipeDown(self)
def test_case_homeMineCase6(self): while True: try: self.driver.find_element_by_id( Page_config.PageID.settingID).click() break except Exception, e: Swipe_op.SwipeDown(self)
def setUpClass(cls): # 更改Appium启动参数 appium_config.desired_caps['automationName'] = 'Uiautomator2' # 启动Appium appium_config.AppiumStart(cls) # 获取手机屏幕分辨率 cls.x = cls.driver.get_window_size()['width'] cls.y = cls.driver.get_window_size()['height'] time.sleep(5) # 判断是否存在收藏提醒 if go_comic.go_comic(cls) is True: print '存在收藏更新提醒,点击关闭测试通过' else: pass # 进入分类页面 cls.driver.find_element_by_id(Page_config.PageID.tab_category).click() # 分类页面中随机选择一部漫画进入 for x in range(1, random.randint(3, 31)): Swipe_op.SwipeDown(cls) element_names = cls.driver.find_elements_by_id('com.xmtj.mkz:id/name') element_name = element_names[random.randint(3, len(element_names) - 1)] element_name.click() try: WebDriverWait(cls.driver, 30).until(lambda driver: driver.find_element_by_id( Page_config.PageID.comic_read)) except Exception, e: # 判断超时时,点击刷新页面 for i in range(1, 21): try: element_refresh = cls.driver.find_elements_by_id( 'com.xmtj.mkz:id/refresh') if element_refresh is not None: element_refresh.click() break except Exception, e: print '网络出错,页面未能刷新' continue
class HomePageTest(unittest.TestCase): global driver # 初始化环境 @classmethod def setUpClass(cls): # 更改Appium启动参数 appium_config.desired_caps['automationName'] = 'Appium' # 启动Appium appium_config.AppiumStart(cls) cls.extend = Appium_Extend(cls.driver) # 获取手机屏幕分辨率 cls.x = cls.driver.get_window_size()['width'] cls.y = cls.driver.get_window_size()['height'] # 判断当前手机网络 network_num = cls.driver.network_connection if network_num != 6: # 开启手机wifi网络 cls.driver.set_network_connection(ConnectionType.WIFI_ONLY) time.sleep(6) # 判断是否存在收藏提醒 if go_comic.go_comic(cls) is True: print '存在收藏更新提醒,点击关闭测试通过' else: pass # 设置首页顶部tab element1 = cls.driver.find_element_by_id(Page_config.PageID.homeTab) cls.elements1 = element1.find_elements_by_class_name( 'android.widget.FrameLayout') '''推荐页面各版块点击跳转操作''' def home_module(self, ModuleID, titleText, GridID, gridNum): # 查找页面中的版块标题区域,测试点击返回流程 while True: try: self.driver.find_element_by_id(ModuleID).click() break except Exception, e: Swipe_op.SwipeDown(self) if titleText != u'新作尝鲜': self.driver.wait_activity('.business.main.list.ComicListActivity', 5, 0.5) self.assertEqual( self.driver.find_element_by_id('com.xmtj.mkz:id/title').text, titleText) self.driver.find_element_by_accessibility_id('转到上一层级').click() time.sleep(2) else: WebDriverWait(self.driver, 30).until(lambda driver: driver.find_element_by_id( 'com.xmtj.mkz:id/count')) element_ranklatest = self.driver.find_element_by_id( 'com.xmtj.mkz:id/rank_latest') self.assertEqual(element_ranklatest.get_attribute('selected'), u'true') self.elements1[2].click() # 根据各版块中的漫画数量定位展示 while True: try: element_Grid = self.driver.find_element_by_id(GridID) elements_Grid = element_Grid.find_elements_by_id( 'com.xmtj.mkz:id/name') self.assertEqual(len(elements_Grid), gridNum) break except Exception, e: Swipe_op.SwipeDown(self)
else: print '用户收藏数异常,显示为%d,测试错误!!!!!' % element_collectNum # 滑动相对坐标 x1 = 380.00 / 720 y1 = 1000.00 / 1280 y2 = 530.00 / 1280 # 滑动实际坐标 x_swipe1 = int(x1 * self.x) y_swipe1 = int(y1 * self.y) y_swipe2 = int(y2 * self.y) # 随机滑动页面后,选择第一个动态内容 self.driver.swipe(x_swipe1, y_swipe1, x_swipe1, y_swipe2, 800) swipe_max = random.randint(1, 21) for n in range(1, swipe_max): Swipe_op.SwipeDown(self) element_activitys = self.driver.find_elements_by_id( 'com.xmtj.mkz:id/tv_activity') element_details = self.driver.find_elements_by_id( 'com.xmtj.mkz:id/detail_layout') element_activity = element_activitys[1] element_detail = element_details[1] print '动态页面随机选择的动态为:%s' % element_activity.text # 判断该动态类型,并点击跳转测试 factor = '收藏|评论|打赏|月票' if re.search(factor, str(element_activity.text)) is not None: element_comic_name = element_detail.find_element_by_id( Page_config.PageID.comic_name).text element_detail.click() WebDriverWait(self.driver,
def test_case_categoryTest(self): element = self.driver.find_element_by_id( 'com.xmtj.mkz:id/label_layout') elements_cat = element.find_elements_by_class_name( 'android.widget.TextView') # 分类滑动相对坐标 x1 = 500.00 / 720 x2 = 300.00 / 720 y1 = 190.00 / 1280 # 分类滑动实际坐标 x_swipe1 = int(x1 * self.x) x_swipe2 = int(x2 * self.x) y_swipe1 = int(y1 * self.y) # 随机滑动分类栏并随机点击 for swipe in range(0, random.randint(0, 9)): self.driver.swipe(x_swipe1, y_swipe1, x_swipe2, y_swipe1, 800) cat_num = random.randint(0, len(elements_cat) - 1) elements_cat[cat_num].click() print '点击的漫画分类为:%s' % elements_cat[cat_num].text time.sleep(1) # 随机点击状态分类 list1 = [ 'com.xmtj.mkz:id/status_all', 'com.xmtj.mkz:id/status_serialize', 'com.xmtj.mkz:id/status_end' ] status_num1 = random.randint(0, 2) element_status1 = self.driver.find_element_by_id(list1[status_num1]) element_status1.click() print '点击的漫画状态分类为:%s' % element_status1.text time.sleep(1) # 随机点击售价分类 list2 = [ 'com.xmtj.mkz:id/price_all', 'com.xmtj.mkz:id/price_free', 'com.xmtj.mkz:id/price_fee', 'com.xmtj.mkz:id/price_vip' ] status_num2 = random.randint(0, 3) element_status2 = self.driver.find_element_by_id(list2[status_num2]) element_status2.click() print '点击的漫画售价分类为:%s' % element_status2.text try: WebDriverWait(self.driver, 20).until(lambda driver: driver.find_element_by_id( 'com.xmtj.mkz:id/chapter')) # 随机下滑页面 swipe_num = random.randint(0, 11) for x in range(0, swipe_num): Swipe_op.SwipeDown(self) # 随机选择分类列表中的漫画,并判断是否连载/完结 elements_comic = self.driver.find_elements_by_id( 'com.xmtj.mkz:id/chapter') element_comic = elements_comic[random.randint( 0, len(elements_comic) - 1)] if element_comic.text.split('至')[0] == '更新': print '漫画处于连载状态' elif element_comic.text == '完结': print '漫画处于完结状态' element_comic.click() WebDriverWait(self.driver, 20).until(lambda driver: driver.find_element_by_id( 'com.xmtj.mkz:id/top_bg_layout')) element_comic = self.driver.find_element_by_id( 'com.xmtj.mkz:id/top_bg_layout') comic_name = element_comic.find_element_by_id( Page_config.PageID.comic_name).text print '分类测试点击的漫画为:%s' % comic_name self.driver.find_element_by_id(Page_config.PageID.top_back).click() except Exception, e: self.driver.find_element_by_id('com.xmtj.mkz:id/empty_text') print '该分类下无漫画数据'
def test_case_homeMineCase1(self): # 未登录时,按钮显示的文案 element_tv1 = self.driver.find_element_by_id('com.xmtj.mkz:id/tv_name') element_tv2 = self.driver.find_element_by_id( Page_config.PageID.myLogin) self.assertEqual(element_tv1.text, u'点击头像登录呦') self.assertEqual(element_tv2.text, u'登录后可以尽情的享受更多的功能~') # 点击头像跳转登录页面 self.driver.find_element_by_id(Page_config.PageID.myImgID).click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.logInID)) self.driver.find_element_by_accessibility_id('转到上一层级').click() print '未登录状态下点击头像跳转登录页面测试通过' # VIP状态及页面跳转 element_vip_info = self.driver.find_element_by_id( Page_config.PageID.vip_info) self.assertEqual(element_vip_info.text, u'未开通VIP') element_getVip = self.driver.find_element_by_id( 'com.xmtj.mkz:id/tv_get_vip_tip') self.assertEqual(element_getVip.text, u'开通VIP 惊喜多多') element_getVip.click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.logInID)) self.driver.find_element_by_accessibility_id('转到上一层级').click() print '未登录状态下点击VIP状态栏跳转登录页面测试通过' # 元宝、月票及我的账户跳转账户页面,随机选择 element_list1 = [ Page_config.PageID.myMoney, Page_config.PageID.myTicket, Page_config.PageID.accountID ] self.driver.find_element_by_id(element_list1[random.randint( 0, len(element_list1) - 1)]).click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.titleID)) # 判断跳转我的账户页面的各元素 self.driver.find_element_by_id('com.xmtj.mkz:id/please_login').click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.logInID)) self.driver.find_element_by_accessibility_id('转到上一层级').click() # 元宝与月票数应均为0 element_value1 = self.driver.find_element_by_id( 'com.xmtj.mkz:id/money_value') element_value2 = self.driver.find_element_by_id( 'com.xmtj.mkz:id/ticket_value') self.assertEqual(element_value1.text, '0') self.assertEqual(element_value1.text, element_value2.text) # 点击元宝的充值按钮跳转 self.driver.find_element_by_id(Page_config.PageID.chargeID).click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.titleID)) element_charge_title = self.driver.find_element_by_id( Page_config.PageID.titleID).text self.assertEqual(element_charge_title, u'充值元宝') while True: try: self.driver.find_element_by_id( Page_config.PageID.pay_buttonID).click() WebDriverWait( self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.logInID)) break except Exception, e: Swipe_op.SwipeDown(self)
def test_case_homeMineCase5(self): self.driver.find_element_by_id(Page_config.PageID.messageID).click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( 'com.xmtj.mkz:id/tv_title')) # 随机向下滑动页面 swipe_max = random.randint(1, 21) for n in range(1, swipe_max): Swipe_op.SwipeDown(self) # 选择一个消息内容 element_titles = self.driver.find_elements_by_id( 'com.xmtj.mkz:id/tv_title') element_title = element_titles[random.randint(1, 2)] try: # 定位随机选择的消息是否存在小红点 element_redDot = self.driver.find_element_by_android_uiautomator( 'new UiSelector().text("%s").fromParent(new UiSelector().resourceId("com.xmtj.mkz:id/red_dot").index(0))' % element_title.text) print '此条消息未读:%s' % element_title.text # 判断消息类型,并点击跳转做对比 if re.search('关注', str(element_title.text)): element_tvname = self.driver.find_element_by_android_uiautomator( 'new UiSelector().text("%s").fromParent(new UiSelector().resourceId("com.xmtj.mkz:id/tv_other_name").index(1))' % element_title.text).text re.search(str(element_tvname), str(element_title.text)) element_title.click() WebDriverWait( self.driver, 30).until(lambda driver: driver.find_element_by_id( 'com.xmtj.mkz:id/tv_name')) tv_name = self.driver.find_element_by_id( 'com.xmtj.mkz:id/tv_name').text re.search(str(tv_name), str(element_tvname)) print '关注类消息点击跳转测试通过' elif re.search('回复', str(element_title.text)): element_comic = self.driver.find_element_by_android_uiautomator( 'new UiSelector().text("%s").fromParent(new UiSelector().resourceId("com.xmtj.mkz:id/comic_name").index(0))' % element_title.text).text # 获取回复的内容 element_reply = self.driver.find_element_by_android_uiautomator( 'new UiSelector().text("%s").fromParent(new UiSelector().resourceId("com.xmtj.mkz:id/tv_reply").index(3))' % element_title.text).text element_title.click() WebDriverWait( self.driver, 30).until(lambda driver: driver.find_element_by_id( Page_config.PageID.comic_name)) element_comic2 = self.driver.find_element_by_id( 'com.xmtj.mkz:id/top_bg_layout') comic_name2 = element_comic2.find_element_by_id( Page_config.PageID.comic_name).text self.assertEqual(element_comic, comic_name2) print '评论回复的内容为:%s,回复的漫画为:%s,漫画点击跳转测试通过' % (element_reply, element_comic) self.driver.find_element_by_id(Page_config.PageID.top_back).click() try: if element_redDot is not None: print '阅读消息红点消失功能测试通过' except Exception, e: print '已读消息红点消失测试失败' except Exception, e: print '此条消息已读:%s' % element_title.text if re.search('关注', str(element_title.text)): element_tvname = self.driver.find_element_by_android_uiautomator( 'new UiSelector().text("%s").fromParent(new UiSelector().resourceId("com.xmtj.mkz:id/tv_other_name").index(1))' % element_title.text).text re.search(str(element_tvname), str(element_title.text)) element_title.click() WebDriverWait( self.driver, 30).until(lambda driver: driver.find_element_by_id( 'com.xmtj.mkz:id/tv_name')) tv_name = self.driver.find_element_by_id( 'com.xmtj.mkz:id/tv_name').text re.search(str(tv_name), str(element_tvname)) print '关注类消息点击跳转测试通过' elif re.search('回复', str(element_title.text)): element_comic = self.driver.find_element_by_android_uiautomator( 'new UiSelector().text("%s").fromParent(new UiSelector().resourceId("com.xmtj.mkz:id/comic_name").index(0))' % element_title.text).text element_reply = self.driver.find_element_by_android_uiautomator( 'new UiSelector().text("%s").fromParent(new UiSelector().resourceId("com.xmtj.mkz:id/tv_reply").index(2))' % element_title.text).text element_title.click() WebDriverWait( self.driver, 30).until(lambda driver: driver.find_element_by_id( Page_config.PageID.comic_name)) element_comic2 = self.driver.find_element_by_id( 'com.xmtj.mkz:id/top_bg_layout') comic_name2 = element_comic2.find_element_by_id( Page_config.PageID.comic_name).text self.assertEqual(element_comic, comic_name2) print '评论回复的内容为:%s,回复的漫画为:%s,漫画点击跳转测试通过' % (element_reply, element_comic) self.driver.find_element_by_id(Page_config.PageID.top_back).click()
def test_case_homeMineCase4(self): self.driver.find_element_by_id(Page_config.PageID.accountID).click() WebDriverWait(self.driver, 30).until(lambda driver: driver.find_element_by_id( 'com.xmtj.mkz:id/money_value')) # 获取元宝数 element_valueText = self.driver.find_element_by_id( 'com.xmtj.mkz:id/money_value').text # 点击元宝的充值按钮跳转 self.driver.find_element_by_id(Page_config.PageID.chargeID).click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.titleID)) element_charge_title = self.driver.find_element_by_id( Page_config.PageID.titleID).text element_moneyText = self.driver.find_element_by_id( Page_config.PageID.moneyID).text self.assertEqual(element_charge_title, u'充值元宝') self.assertEqual(element_valueText, element_moneyText) self.driver.find_element_by_accessibility_id('转到上一层级').click() print '登录状态下点击充值元宝跳转充值元宝页面测试通过' # 点击VIP状态跳转 element_vip_time = self.driver.find_element_by_id( Page_config.PageID.vip_time).text element_buyVip = self.driver.find_element_by_id( Page_config.PageID.buy_vipID) if element_vip_time == '开通VIP 惊喜多多': self.assertEqual(element_buyVip.text, u'去开通') else: self.assertEqual(element_buyVip.text, u'去续费') element_buyVip.click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.vip_info)) self.driver.find_element_by_accessibility_id('转到上一层级').click() print '登录状态下点击我的账户中去续费跳转VIP付费页面测试通过' # 点击购买月票跳转 element_ticket = self.driver.find_element_by_id( Page_config.PageID.buy_month_ticketID) self.assertEqual(element_ticket.text, u'购买') element_ticket.click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.ticket_info)) self.driver.find_element_by_accessibility_id('转到上一层级').click() print '登录状态下点击月票链接跳转VIP付费页面测试通过' # 判断登录账户资产记录区域中的信息 element_tab = self.driver.find_element_by_id( 'com.xmtj.mkz:id/tab_layout') element_list2 = element_tab.find_elements_by_class_name( 'android.widget.FrameLayout') for num in range(0, 3): element_list2[num].click() element_list2text = element_list2[num].find_element_by_class_name( 'android.widget.TextView').text try: WebDriverWait(self.driver, 30).until(lambda driver: driver. find_element_by_id('android:id/list')) for swipeNum in range(1, random.randint(3, 11)): Swipe_op.SwipeDown(self) element_contentList = self.driver.find_element_by_id( 'android:id/list') element_contents = element_contentList.find_elements_by_id( 'com.xmtj.mkz:id/content') element_content = element_contents[random.randint( 0, len(element_contents) - 1)] if num == 0: text = '打赏|购买|增加|减少' re.search(text, str(element_content.text)) elif num == 1: re.search('VIP', str(element_content.text)) elif num == 2: re.search('月票', str(element_content.text)) print '随机选择的%s记录为:%s' % (element_list2text, element_content.text) except Exception, e: WebDriverWait( self.driver, 30).until(lambda driver: driver.find_element_by_id( 'com.xmtj.mkz:id/empty_text')) element_empty_text = self.driver.find_element_by_id( 'com.xmtj.mkz:id/empty_text') self.assertEqual(element_empty_text.text, u'这里空空如也') print '%s记录为空' % element_list2text time.sleep(3)
class HomeMineTest(unittest.TestCase): global driver # 初始化环境 @classmethod def setUpClass(cls): # 更改Appium启动参数 appium_config.desired_caps['automationName'] = 'Appium' # 启动Appium appium_config.AppiumStart(cls) # 获取手机屏幕分辨率 cls.x = cls.driver.get_window_size()['width'] cls.y = cls.driver.get_window_size()['height'] # 进入我的页面 time.sleep(5) cls.driver.find_element_by_id(Page_config.PageID.homeMy).click() # 退出测试 @classmethod def tearDownClass(cls): cls.driver.quit() # 未登录状态,我的页面各页面跳转 def test_case_homeMineCase1(self): # 未登录时,按钮显示的文案 element_tv1 = self.driver.find_element_by_id('com.xmtj.mkz:id/tv_name') element_tv2 = self.driver.find_element_by_id( Page_config.PageID.myLogin) self.assertEqual(element_tv1.text, u'点击头像登录呦') self.assertEqual(element_tv2.text, u'登录后可以尽情的享受更多的功能~') # 点击头像跳转登录页面 self.driver.find_element_by_id(Page_config.PageID.myImgID).click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.logInID)) self.driver.find_element_by_accessibility_id('转到上一层级').click() print '未登录状态下点击头像跳转登录页面测试通过' # VIP状态及页面跳转 element_vip_info = self.driver.find_element_by_id( Page_config.PageID.vip_info) self.assertEqual(element_vip_info.text, u'未开通VIP') element_getVip = self.driver.find_element_by_id( 'com.xmtj.mkz:id/tv_get_vip_tip') self.assertEqual(element_getVip.text, u'开通VIP 惊喜多多') element_getVip.click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.logInID)) self.driver.find_element_by_accessibility_id('转到上一层级').click() print '未登录状态下点击VIP状态栏跳转登录页面测试通过' # 元宝、月票及我的账户跳转账户页面,随机选择 element_list1 = [ Page_config.PageID.myMoney, Page_config.PageID.myTicket, Page_config.PageID.accountID ] self.driver.find_element_by_id(element_list1[random.randint( 0, len(element_list1) - 1)]).click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.titleID)) # 判断跳转我的账户页面的各元素 self.driver.find_element_by_id('com.xmtj.mkz:id/please_login').click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.logInID)) self.driver.find_element_by_accessibility_id('转到上一层级').click() # 元宝与月票数应均为0 element_value1 = self.driver.find_element_by_id( 'com.xmtj.mkz:id/money_value') element_value2 = self.driver.find_element_by_id( 'com.xmtj.mkz:id/ticket_value') self.assertEqual(element_value1.text, '0') self.assertEqual(element_value1.text, element_value2.text) # 点击元宝的充值按钮跳转 self.driver.find_element_by_id(Page_config.PageID.chargeID).click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.titleID)) element_charge_title = self.driver.find_element_by_id( Page_config.PageID.titleID).text self.assertEqual(element_charge_title, u'充值元宝') while True: try: self.driver.find_element_by_id( Page_config.PageID.pay_buttonID).click() WebDriverWait( self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.logInID)) break except Exception, e: Swipe_op.SwipeDown(self) for x in range(1, 3): self.driver.find_element_by_accessibility_id('转到上一层级').click() print '未登录状态下点击充值元宝跳转登录页面测试通过' # 点击购买月票跳转 element_ticket = self.driver.find_element_by_id( Page_config.PageID.buy_month_ticketID) self.assertEqual(element_ticket.text, u'购买') element_ticket.click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.logInID)) self.driver.find_element_by_accessibility_id('转到上一层级').click() print '未登录状态下点击购买月票跳转登录页面测试通过' # 点击VIP状态跳转 element_vip_time = self.driver.find_element_by_id( Page_config.PageID.vip_time) self.assertEqual(element_vip_time.text, u'开通VIP 惊喜多多') element_buyVip = self.driver.find_element_by_id( Page_config.PageID.buy_vipID) self.assertEqual(element_buyVip.text, u'去开通') element_buyVip.click() WebDriverWait(self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.vip_info)) element_vipText = self.driver.find_element_by_id( Page_config.PageID.vip_info).text self.assertEqual(element_vipText, u'当前为游客,请登录后开通VIP') while True: try: self.driver.find_element_by_id( Page_config.PageID.pay_buttonID).click() WebDriverWait( self.driver, 15).until(lambda driver: driver.find_element_by_id( Page_config.PageID.logInID)) break except Exception, e: Swipe_op.SwipeDown(self)
element_comic) self.driver.find_element_by_id(Page_config.PageID.top_back).click() # 测试全部已读按钮功能 try: element_readStatus = self.driver.find_element_by_id( 'com.xmtj.mkz:id/tv_status') element_readStatus.click() time.sleep(3) try: self.driver.find_element_by_id('com.xmtj.mkz:id/tv_status') print '点击全部已读,该按钮仍然存在' except Exception, e: # 将页面滑至顶部 for n in range(1, swipe_max): Swipe_op.SwipeUp(self) # 检查是否仍然存在红点 while True: try: self.driver.find_element_by_android_uiautomator( 'new UiSelector().text("%s").fromParent(new UiSelector().resourceId("com.xmtj.mkz:id/red_dot").index(0))' % element_title.text) print '点击全部已读,仍然存在小红点' except Exception, e: Swipe_op.SwipeDown(self) try: self.driver.find_element_by_id( 'com.xmtj.mkz:id/no_more') break except Exception, e: continue