Esempio n. 1
0
def my_guess(driver):
    '''
    我的竞猜获取竞猜内容
    '''
    #点击我的竞猜按钮
    driver.find_elements_by_xpath(
        '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/*'
    )[4].click()
    while True:
        try:
            #随机点击一个我参与的竞猜
            random_click(driver,
                         '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/'
                         )[0].click()
            #向上滑动
            slide_up(driver)
            #选择竞猜一个
            #driver.find_element_by_xpath(
            #    '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[' + str(len(driver.find_elements_by_xpath(
            #        '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[*]'))) + ']/UIATextField[1]').click()
            driver.find_element_by_xpath(
                '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell['
                + str(
                    len(
                        driver.find_elements_by_xpath(
                            '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[*]'
                        ))) + ']/UIATextField[1]').send_keys('3')
            #向上滑动取消竞猜
            driver.swipe(100, 145, 100, 120)
            #点击竞猜
            driver.find_element_by_xpath(
                '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIAButton[1]'
            ).click()
            #点击确认购买
            driver.find_element_by_name(u'购买').click()
            break
        except:
            driver.find_element_by_xpath(u'返回').click()
            continue
            #等待购买成功
    time.sleep(3)
    share(driver, to=random.choice([u'朋友圈', u'微信', u'微博']))
    driver.find_element_by_name(u'返回').click()
    #返回上一级
    driver.find_element_by_xpath(
        '//UIAApplication[1]/UIAWindow[1]/UIANavigationBar[1]/UIAButton[1]'
    ).click()
Esempio n. 2
0
def my_guess(driver):
    '''
    我的竞猜获取竞猜内容
    '''
    #点击我的竞猜按钮
    driver.find_elements_by_xpath(
        '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/*')[4].click()
    while True:
        try:
            #随机点击一个我参与的竞猜
            random_click(driver, '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/')[0].click()
            #向上滑动
            slide_up(driver)
            #选择竞猜一个
            #driver.find_element_by_xpath(
            #    '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[' + str(len(driver.find_elements_by_xpath(
            #        '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[*]'))) + ']/UIATextField[1]').click()
            driver.find_element_by_xpath(
                '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[' + str(
                    len(driver.find_elements_by_xpath(
                        '//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[*]'))) + ']/UIATextField[1]').send_keys(
                '3')
            #向上滑动取消竞猜
            driver.swipe(100, 145, 100, 120)
            #点击竞猜
            driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIAButton[1]').click()
            #点击确认购买
            driver.find_element_by_name(u'购买').click()
            break
        except:
            driver.find_element_by_xpath(u'返回').click()
            continue
            #等待购买成功
    time.sleep(3)
    share(driver, to=random.choice([u'朋友圈', u'微信', u'微博']))
    driver.find_element_by_name(u'返回').click()
    #返回上一级
    driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIANavigationBar[1]/UIAButton[1]').click()
Esempio n. 3
0
    def test_share(self):
        test = _User.Query.get(username="******")
        followers = Following.Query.filter(user=test)
        print "%d people follow test" %len(followers)

        notifications1 = Notification.Query.filter(fromUser="******")
        print "before insert number of notification sent from %s is %d." % ("test",len(notifications1))
        share(True,"test", "haotian", "1234")
        # test if the request 
        notifications2 = Notification.Query.filter(fromUser="******")
        print "after insert number of notification sent from %s is %d." % ("test",len(notifications2))
        self.assertTrue(len(notifications2)-len(notifications1)==0)


        # second test case on chris
        chris = _User.Query.get(username="******")
        followers = Following.Query.filter(user=chris)
        print "%d people follow chris" %len(followers)

        chris1 = Notification.Query.filter(fromUser="******")
        print "before insert number of notification sent from %s is %d." % ("Chris",len(chris1))
        share(True, "Chris", "guoqiao", "123")
        # after the share of notifications
        chris2 = Notification.Query.filter(fromUser="******")
        print "after insert number of notification sent from %s is %d." % ("Chris",len(chris2))


        self.assertTrue(len(chris1)==len(chris2))
        # thrid test case on 
        test2 = _User.Query.get(username="******")
        followers = Following.Query.filter(user=test2)
        print "%d people follow Test2" %len(followers)

        test2 = Notification.Query.filter(fromUser="******")
        print "before insert number of notification sent from %s is %d." % ("Test2",len(test2))
        share(True, "Test2", "guoqiao", "123")
        # after the share of notifications
        test2_ = Notification.Query.filter(fromUser="******")
        print "after insert number of notification sent from %s is %d." % ("Test2",len(test2_))
        self.assertTrue(len(test2)==len(test2_))