def my_profile(driver): #点击我的资料进入到我的资料修改页面 driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/*')[5].click() #查看是否有历史头像 if driver.find_elements_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[2]/*'): log_info('have history picture') else: log_info('no history picture') #修改个人昵称 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[3]/UIAStaticText[2]').click() #输入修改的个人昵称 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/UIATextField[1]').send_keys(randomCN(3)) #保存修改 driver.find_element_by_name(u'保存').click() #点击修改个性签名 #qm = driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]').location #qm_s = driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]').size #driver.swipe(int(qm['x']) + (int(qm_s['width']) / 2), int(qm['y']) + (int(qm_s['height']) / 2), # int(qm['x']) + (int(qm_s['width']) / 2), int(qm['y']) + (int(qm_s['height']) / 2)) #输入个性签名 #driver.find_element_by_xpath( # '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/UIATextView[1]').send_keys(randomCN(10)) #点击保存 #driver.find_element_by_name(u'保存').click() time.sleep(2) #随机选择性别 random.choice(driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[5]/UIAButton[*]')).click() #点击返回 driver.find_element_by_name(u'返回').click()
def my_look(driver): ''' 我的关注页面随机选择一个人查看他的个人资料 ''' #点击进入我的关注页面 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/UIAButton[1]').click() log_info( 'have ' + str(len(driver.find_elements_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*'))) + 's ') #随机选择一个人 random_click(driver, '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/')[1].click() #获取个人资料 person = {'name': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableGroup[1]/UIAStaticText[1]').text, 'follower': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableGroup[1]/UIAStaticText[3]').text[:-3], 'gender': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]/UIAStaticText[1]').text[3:], 'addr': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]/UIAStaticText[2]').text[3:], 'birthday': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]/UIAStaticText[3]').text[3:] } log_info("His/her profile: name " + person['name'] + ", follower " + person['follower'] + ", gender " + person[ 'gender'] + ", addr " + person['addr'] + ", birthday " + person['birthday']) #返回到我的个人资料主页 for i in range(2): driver.find_element_by_name(u'返回').click()
def my_fans(driver): ''' 我的粉丝页面随机选择一个人发送私信 ''' #点击我的粉丝 driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/*' )[3].click() #随机选择一个人 random_click( driver, '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/')[1].click() #获取个人资料 person = { 'name': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableGroup[1]/UIAStaticText[1]' ).text, 'follower': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableGroup[1]/UIAStaticText[3]' ).text[:-3], 'gender': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]/UIAStaticText[1]' ).text[3:], 'addr': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]/UIAStaticText[2]' ).text[3:], 'birthday': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]/UIAStaticText[3]' ).text[3:] } log_info("His/her profile: name " + person['name'] + ", follower " + person['follower'] + ", gender " + person['gender'] + ", addr " + person['addr'] + ", birthday " + person['birthday']) #点击发送私信 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/UIAButton[2]' ).click() #点击输入框 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATextView[1]').click() #输入要发送内容 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATextView[1]').send_keys(u'你好') driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[2]/*/UIAButton')[-3].click() #print driver.find_elements_by_xpath( # '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[*]/*')[-1].location['x'] #返回上一级 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIANavigationBar[1]/UIAButton[2]' ).click() #返回到我的个人页面 for i in range(2): driver.find_element_by_name(u'返回').click()
def send_daoju(driver): ''' ::driver 发送当前页面的driver 在八卦详情页面,赠送道具 ''' #点击评论上方的道具 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/UIAButton[1]' ).click() #总共6种道具 依次点击赠送 for i in range(1, 7): if i % 4 == 0: print u'要开始滑了' time.sleep(2) #往左拉一点 driver.swipe(246, 384, 90, 384) time.sleep(2) #选中道具 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAButton[' + str(i) + ']').click() #点击赠送 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIAButton[3]').click() #判断之前有没有该道具 if driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[4]/UIAAlert[1]/UIAScrollView[1]/UIAStaticText[1]') and \ driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[4]/UIAAlert[1]/UIAScrollView[1]/UIAStaticText[1]').text[ -4:] == u'数量不够': #如果没有点击确定购买 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[4]/UIAAlert[1]/UIACollectionView[1]/UIACollectionCell[2]' ).click() #等待购买成功 try: WebDriverWait(driver, 10).until(lambda x: x.find_element_by_xpath( ' //UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAButton[4]' )) #log_info(driver.find_element_by_xpath( # '//UIAApplication[1]/UIAWindow[1]/UIANavigationBar[1]/UIAStaticText[1]').text + u'页面' + # daoju_dirt[i] + u'购买成功') log_info('buy daoju sucess') except: #log_error(driver.find_element_by_xpath( # '//UIAApplication[1]/UIAWindow[1]/UIANavigationBar[1]/UIAStaticText[1]').text + u'页面' + # daoju_dirt[i] + u'购买失败') log_error('buy daoju error') print_erro_picture(driver, save_path=save_path) #去除下面显示的道具 driver.swipe(180, 200, 180, 180)
def send_daoju(driver): ''' ::driver 发送当前页面的driver 在八卦详情页面,赠送道具 ''' #点击评论上方的道具 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/UIAButton[1]').click() #总共6种道具 依次点击赠送 for i in range(1, 7): if i % 4 == 0: print u'要开始滑了' time.sleep(2) #往左拉一点 driver.swipe(246, 384, 90, 384) time.sleep(2) #选中道具 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAButton[' + str(i) + ']').click() #点击赠送 driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIAButton[3]').click() #判断之前有没有该道具 if driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[4]/UIAAlert[1]/UIAScrollView[1]/UIAStaticText[1]') and \ driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[4]/UIAAlert[1]/UIAScrollView[1]/UIAStaticText[1]').text[ -4:] == u'数量不够': #如果没有点击确定购买 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[4]/UIAAlert[1]/UIACollectionView[1]/UIACollectionCell[2]').click() #等待购买成功 try: WebDriverWait(driver, 10).until( lambda x: x.find_element_by_xpath( ' //UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAButton[4]')) #log_info(driver.find_element_by_xpath( # '//UIAApplication[1]/UIAWindow[1]/UIANavigationBar[1]/UIAStaticText[1]').text + u'页面' + # daoju_dirt[i] + u'购买成功') log_info('buy daoju sucess') except: #log_error(driver.find_element_by_xpath( # '//UIAApplication[1]/UIAWindow[1]/UIANavigationBar[1]/UIAStaticText[1]').text + u'页面' + # daoju_dirt[i] + u'购买失败') log_error('buy daoju error') print_erro_picture(driver, save_path=save_path) #去除下面显示的道具 driver.swipe(180, 200, 180, 180)
def my_look(driver): ''' 我的关注页面随机选择一个人查看他的个人资料 ''' #点击进入我的关注页面 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/UIAButton[1]' ).click() log_info('have ' + str( len( driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*'))) + 's ') #随机选择一个人 random_click( driver, '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/')[1].click() #获取个人资料 person = { 'name': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableGroup[1]/UIAStaticText[1]' ).text, 'follower': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableGroup[1]/UIAStaticText[3]' ).text[:-3], 'gender': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]/UIAStaticText[1]' ).text[3:], 'addr': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]/UIAStaticText[2]' ).text[3:], 'birthday': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]/UIAStaticText[3]' ).text[3:] } log_info("His/her profile: name " + person['name'] + ", follower " + person['follower'] + ", gender " + person['gender'] + ", addr " + person['addr'] + ", birthday " + person['birthday']) #返回到我的个人资料主页 for i in range(2): driver.find_element_by_name(u'返回').click()
def modify_guess(self): save_path = '/Users/lonres/Pictures/resultpic/' driver = webdriver.PhantomJS() self.accept_next_alert = True driver.maximize_window() driver.get(self.url) driver.find_element_by_xpath('//*[@id="wrap"]/nav/div/div[2]/div/a').click() driver.find_element_by_id('login').send_keys('aima') driver.find_element_by_id('password').send_keys('aima') driver.find_element_by_id('submit').click() driver.find_element_by_xpath('//*[@id="wrap"]/div/div[1]/ul/li[2]/a').click() driver.find_element_by_xpath('//*[@id="wrap"]/div/div[4]/ul/li[2]/a').click() submit_list = find_guess(driver, self.guess_title).find_elements_by_id('submit') if len(submit_list) == 4: log_info("Guess issued failed, it's issued!!!") elif len(submit_list) == 3: submit_list[0].click() driver.get_screenshot_as_file(save_path+'screen_hires_success.png') driver.quit()
def my_profile(driver): #点击我的资料进入到我的资料修改页面 driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/*' )[5].click() #查看是否有历史头像 if driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[2]/*' ): log_info('have history picture') else: log_info('no history picture') #修改个人昵称 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[3]/UIAStaticText[2]' ).click() #输入修改的个人昵称 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/UIATextField[1]' ).send_keys(randomCN(3)) #保存修改 driver.find_element_by_name(u'保存').click() #点击修改个性签名 #qm = driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]').location #qm_s = driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]').size #driver.swipe(int(qm['x']) + (int(qm_s['width']) / 2), int(qm['y']) + (int(qm_s['height']) / 2), # int(qm['x']) + (int(qm_s['width']) / 2), int(qm['y']) + (int(qm_s['height']) / 2)) #输入个性签名 #driver.find_element_by_xpath( # '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/UIATextView[1]').send_keys(randomCN(10)) #点击保存 #driver.find_element_by_name(u'保存').click() time.sleep(2) #随机选择性别 random.choice( driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[5]/UIAButton[*]' )).click() #点击返回 driver.find_element_by_name(u'返回').click()
def my_fans(driver): ''' 我的粉丝页面随机选择一个人发送私信 ''' #点击我的粉丝 driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/*')[3].click() #随机选择一个人 random_click(driver, '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/')[1].click() #获取个人资料 person = {'name': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableGroup[1]/UIAStaticText[1]').text, 'follower': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableGroup[1]/UIAStaticText[3]').text[:-3], 'gender': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]/UIAStaticText[1]').text[3:], 'addr': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]/UIAStaticText[2]').text[3:], 'birthday': driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]/UIAStaticText[3]').text[3:] } log_info("His/her profile: name " + person['name'] + ", follower " + person['follower'] + ", gender " + person[ 'gender'] + ", addr " + person['addr'] + ", birthday " + person['birthday']) #点击发送私信 driver.find_element_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/UIAButton[2]').click() #点击输入框 driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATextView[1]').click() #输入要发送内容 driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATextView[1]').send_keys(u'你好') driver.find_elements_by_xpath('//UIAApplication[1]/UIAWindow[2]/*/UIAButton')[-3].click() #print driver.find_elements_by_xpath( # '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[*]/*')[-1].location['x'] #返回上一级 driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIANavigationBar[1]/UIAButton[2]').click() #返回到我的个人页面 for i in range(2): driver.find_element_by_name(u'返回').click()
def modify_guess(self): save_path = '/Users/lonres/Pictures/resultpic/' driver = webdriver.PhantomJS() self.accept_next_alert = True driver.maximize_window() driver.get(self.url) driver.find_element_by_xpath( '//*[@id="wrap"]/nav/div/div[2]/div/a').click() driver.find_element_by_id('login').send_keys('aima') driver.find_element_by_id('password').send_keys('aima') driver.find_element_by_id('submit').click() driver.find_element_by_xpath( '//*[@id="wrap"]/div/div[1]/ul/li[2]/a').click() driver.find_element_by_xpath( '//*[@id="wrap"]/div/div[4]/ul/li[2]/a').click() submit_list = find_guess( driver, self.guess_title).find_elements_by_id('submit') if len(submit_list) == 4: log_info("Guess issued failed, it's issued!!!") elif len(submit_list) == 3: submit_list[0].click() driver.get_screenshot_as_file(save_path + 'screen_hires_success.png') driver.quit()
def board_paging_display(driver, xpaths, page={}): ''' 判断艺人榜上有的几页内容,每页有多少有记录 返回艺人总数 ''' #如果第一次进入先添加第一页有多少个记录 if not page: page[1] = len(driver.find_elements_by_xpath(xpaths)) board_paging_display(driver, xpaths, page) #不是第一次进入且最后一页和倒数第二页的数量是否相同,如果相同就加载了所有的记录,并返回到八卦页面 else: if len(page) > 1 and page[max(page.keys())] == len( driver.find_elements_by_xpath(xpaths)): log_info("There's " + str(max(page.keys())) + " pages in board!") for i in page: log_info('page ' + str(i) + ' : ' + str(page[i])) driver.find_element_by_name('返回').click() #如果没有全加载出来继续翻页并且递归调用 else: slide_up(driver) page[max(page.keys()) + 1] = len( driver.find_elements_by_xpath(xpaths)) board_paging_display(driver, xpaths=xpaths, page=page) return page[max(page.keys())]
def board(driver, mount=0, name=''): ''' 根据人名点击签到未完成 在八卦页面进入到艺人榜,并搜索name艺人并关注,如果已经关注了则不作任何操作 如果name为空,随机选择一个艺人关注 ''' if mount == 0: mount = board_paging_display( driver, '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/./*') * 2 driver.find_element_by_name("艺人榜").click() if name: #查找当前页面有没有叫name的艺人 mount_t = len( driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAStaticText' )) if filter( lambda x: x == name, map( lambda x: x.text, driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAStaticText' ))): #遍历整个页面查找这个艺人的名字 for i in driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAStaticText' ): if i.text == name: #判断签到按钮是否可以点击 if driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAButton' )[int(i.id) % mount_t].is_enabled(): #如果可以点击,点击 print int( driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAButton' )[int(i.id) % mount_t].id) % mount_t driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAButton' )[int(i.id) % mount_t].click() log_info(name + ' Sign in successfully') driver.find_element_by_name('返回').click() break else: #如果不可以点击打印log print driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAButton' )[int(i.id) % mount_t].id print i.text log_info(name + ' Have already signed in') break #如果没有这个人,而且没有加载出全部数据的话滑动加载出下一页 elif not mount_t == mount: slide_up(driver) board(driver, mount, name) else: log_info('The board has not been created!!!') else: #mount = board_paging_display(driver) while True: mount_t = len( driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAButton' )) if mount_t == mount: break else: slide_up(driver) while True: random_element = random.choice( driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAButton' )) try: if random_element.text == u'签到': random_element.click() log_info( str((int(random_element.id) % mount) / 2) + "'s signed in successfully") driver.find_element_by_name('返回').click() break except: continue
def board(driver, mount=0, name=''): ''' 根据人名点击签到未完成 在八卦页面进入到艺人榜,并搜索name艺人并关注,如果已经关注了则不作任何操作 如果name为空,随机选择一个艺人关注 ''' if mount == 0: mount = board_paging_display(driver, '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/./*') * 2 driver.find_element_by_name("艺人榜").click() if name: #查找当前页面有没有叫name的艺人 mount_t = len(driver.find_elements_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAStaticText')) if filter(lambda x: x == name, map(lambda x: x.text, driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAStaticText'))): #遍历整个页面查找这个艺人的名字 for i in driver.find_elements_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAStaticText'): if i.text == name: #判断签到按钮是否可以点击 if driver.find_elements_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAButton')[ int(i.id) % mount_t].is_enabled(): #如果可以点击,点击 print int(driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAButton')[ int(i.id) % mount_t].id) % mount_t driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAButton')[int(i.id) % mount_t].click() log_info(name + ' Sign in successfully') driver.find_element_by_name('返回').click() break else: #如果不可以点击打印log print driver.find_elements_by_xpath( '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAButton')[int(i.id) % mount_t].id print i.text log_info(name + ' Have already signed in') break #如果没有这个人,而且没有加载出全部数据的话滑动加载出下一页 elif not mount_t == mount: slide_up(driver) board(driver, mount, name) else: log_info('The board has not been created!!!') else: #mount = board_paging_display(driver) while True: mount_t = len(driver.find_elements_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAButton')) if mount_t == mount: break else: slide_up(driver) while True: random_element = random.choice( driver.find_elements_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*/UIAButton')) try: if random_element.text == u'签到': random_element.click() log_info(str((int(random_element.id) % mount) / 2) + "'s signed in successfully") driver.find_element_by_name('返回').click() break except: continue