Example #1
0
def xuexiqiangguo(username,passwd,name,share_target):
	config = hehe_common.common_config()
	d = u2.connect()
	unlock_pattern_screen()
	delay_random(2)

	d.app_stop("cn.xuexi.android") 
	d.app_clear('cn.xuexi.android')
	d.app_start("cn.xuexi.android")
	delay_random(5)

	message = hehe_common.get_time() + "\n################\n   开始为" + name + "测试\n################"
	send_messages_by_wechat(d,config,message)

	d.implicitly_wait(25)
	print("Try to LogIn...")
	d(resourceId="cn.xuexi.android:id/et_phone_input").send_keys(username);print("Enter your username");delay_random(2) #输入用户名
	d(resourceId="cn.xuexi.android:id/et_pwd_login").send_keys(passwd);print("Enter your secret");delay_random(2) #输入密码
	d(resourceId="cn.xuexi.android:id/btn_next").click();print("Click the LogIn Button");delay_random(2) #点击登录
	d(resourceId="cn.xuexi.android:id/home_bottom_tab_text", text=u"我的").click();print("Click : 我的");delay_random(10) #点击"我的"
	d(description=u"学习积分").click();print("Click : 学习积分");delay_random(10) #点击学习积分
	d.swipe(0.447, 0.819, 0.541, 0.54);print("Slide : up");delay_random(2) #上滑动
	d.press("back");print("Click 返回");delay_random(3)#点击返回
	
	message = hehe_common.get_time() + "--用户密码正确!登录成功"
	send_messages_by_wechat(d,config,message)
	
	watch_videos(d,config,share_target)
	watch_news(d,config,share_target)
	
	d.implicitly_wait(25)
	time.sleep(5)
	d.app_stop("cn.xuexi.android") 
	d.app_clear('cn.xuexi.android')
	d.screen_off()
Example #2
0
def watch_videos(d, config):
    global title_bar
    global layoutCountInPage
    global scroll_count
    title_bar = None
    interval = int(config["time_interval"]["operate"])
    message = hehe_common.get_time() + "--点击视听学习!开始观看视频"
    send_messages_by_wechat(d, config, message)
    try:
        d(resourceId="cn.xuexi.android:id/home_bottom_tab_icon_group",
          className="android.widget.FrameLayout",
          instance=2).click()
        print("Click 学习")
        delay_random(interval)
        delay_random(interval)  #点击学习
        d(resourceId="cn.xuexi.android:id/home_bottom_tab_text",
          text=u"视听学习").click()  #点击"视频学习"
    except:
        reinitialize_for_watch_videos(d, config)
    delay_random(2)
    d.implicitly_wait(4)
    for shipin in config["shipin"]:
        try:
            scroll_count = 0
            layoutCountInPage = 0
            title_bar = shipin
            message = hehe_common.get_time(
            ) + "--学习[视听学习-" + shipin["title_label"] + "]"
            send_messages_by_wechat(d, config, message)
            d(text=shipin["title_label"]).click()
            delay_random(interval)
            print(("Click : %s") % (shipin["title_label"]))

            #1-表示从第一个layout开始学习(滑动后,新的一页,将从第二个layout开始学习)
            #layout_count-表示共学习30篇
            # need_share-表示是否需要转发到微信
            #1-表示index,现在正在学习的是第几篇
            sequence_watch_vedios_news(d, config, "shipin", 1,
                                       int(shipin["layout_count"]),
                                       change_boolean(shipin["need_share"]), 1)
        except:
            reinitialize_for_watch_videos(d, config)
            reCount = int(shipin["layout_count"]) if (
                layoutCountInPage == 0) else layoutCountInPage
            sequence_watch_vedios_news(d, config, "shipin", 1, reCount,
                                       change_boolean(shipin["need_share"]), 1)
    message = hehe_common.get_time() + "------------结束-------------"
    send_messages_by_wechat(d, config, message)
    d.implicitly_wait(25)
Example #3
0
def share_to_wechat_friends(d,config,is_shipin,need_share,timetotal,index):
	interval = int(config["time_interval"]["operate"])
	try:
		if need_share == True:
			d.click(0.781, 0.9);print("Click 收藏");delay_random(2) #点击收藏
			if is_shipin == "shipin":
				d.click(0.526, 0.167);print("Click ...");time.sleep(0.5)#点击任意,弹出3个点
				d(resourceId="cn.xuexi.android:id/my_video_avatar").click();print("Click 分享...");delay_random(interval) #点击三个点分享按钮
			else:
				d(resourceId="cn.xuexi.android:id/my_news_avatar").click();print("Click 分享...");delay_random(interval) #点击三个点分享按钮
			if d.xpath('//*[@resource-id="cn.xuexi.android:id/share_ui_layout"]').exists: #转发给微信
				d.xpath('//android.widget.GridView/android.widget.RelativeLayout[3]/android.widget.ImageView[1]').click();
				print("Click 转发到微信")
				delay_random(interval) 
			if d.xpath('//*[@resource-id="com.tencent.mm:id/iu"]/android.widget.RelativeLayout[2]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]').exists:#第一个好友
				d.xpath('//*[@resource-id="com.tencent.mm:id/iu"]/android.widget.RelativeLayout[2]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]').click()
				print("Click 微信第一个好友");
				delay_random(interval) #微信第一个好友
				
			if d(resourceId="com.tencent.mm:id/b00").exists:#分享
				d(resourceId="com.tencent.mm:id/b00").click()
				print("Click 分享");
				delay_random(interval) 
			if d(resourceId="com.tencent.mm:id/azz").exists:#返回学习强国
				d(resourceId="com.tencent.mm:id/azz").click();
				print("Click 返回学习强国");
				delay_random(interval)
		
		if is_shipin == "shipin":
			message = hehe_common.get_time() + "--第" + str(index) + "篇视频学习成功, 学习时间约:" + timetotal + "s"
		else:
			message = hehe_common.get_time() + "--第" + str(index) + "篇文章学习成功"
		print(message)
		send_messages_by_wechat(d,config,message)
	except:
		if is_shipin == "shipin":
			message = hehe_common.get_time() + "--第" + str(index) + "篇视频学习失败"
		else:
			message = hehe_common.get_time() + "--第" + str(index) + "篇文章学习失败"
		send_messages_by_wechat(d,config,message)
		try:
			if is_shipin == "shipin":
				reinitialize_for_watch_videos(d,config)# ???????????????????????????????????????????????
			else:
				reinitialize_for_watch_news(d,config)# ???????????????????????????????????????????????
		except:
			pass
Example #4
0
def every_day_operation():
	print(("================= (%s) enter =================") % (hehe_common.get_time()))
	delay_random(6)
	config = hehe_common.common_config()
	for dict in config['userlist']:
		print(("######(%s)#######") % (dict['name']))
		try:
			xuexiqiangguo(dict['username'],dict['passwd'],dict['name'],dict['share'])
			delay_random(120)
		except:
			pass
Example #5
0
def jingdong(username, secret):
    config = hehe_common.common_config()
    firefox_path = config['global_cfg']['firefox_path']
    driver = webdriver.Firefox(firefox_path)
    url = r'https://vip.jd.com/'
    driver.get(url)
    print("===============================")
    print(("%s (%s)") % (driver.title, username))
    print("===============================")

    _thread.start_new_thread(click_invalid_window, (driver, ))

    driver.find_element_by_xpath(
        "//div[@class='login-tab login-tab-r']").click()
    driver.find_element_by_xpath("//input[@id='loginname']").send_keys(
        username)
    driver.find_element_by_xpath("//input[@id='nloginpwd']").send_keys(secret)
    driver.find_element_by_xpath("//div[@class='login-btn']").click()

    time.sleep(3)
    while True:
        #time.sleep(2)
        try:
            jd_verify(driver)
        except:
            print("try----")
            break
    time.sleep(5)

    try:
        if driver.find_element_by_xpath(
                "//span[@class='icon-sign']").is_displayed():
            driver.find_element_by_xpath("//span[@class='icon-sign']").click()
            print("%s---已为账户%s领取京豆" % (hehe_common.get_time(), username))
    except:
        pass
    #driver.find_element_by_xpath("//a[contains(text(),'我的京东')]").click()
    print("%s---已为账户%s领取京豆" % (hehe_common.get_time(), username))
    print("退出浏览器")
    driver.quit()
Example #6
0
def watch_news(d,config,share_target):
	interval = int(config["time_interval"]["operate"])
	message = hehe_common.get_time() + "--点击中心学习按钮!开始阅读文章"
	send_messages_by_wechat(d,config,message)
	try:
		d(resourceId="cn.xuexi.android:id/home_bottom_tab_icon_group", className="android.widget.FrameLayout", instance=2).click();print("Click 学习");delay_random(interval);delay_random(interval)#点击学习
	except:
		reinitialize_for_watch_news(d,config)
	delay_random(2)
	d.implicitly_wait(4)
	for news in config["news"]:
		message = hehe_common.get_time() + "--学习[视听学习-" + news["title_label"] + "]"
		send_messages_by_wechat(d,config,message)
		d(text=news["title_label"]).click();delay_random(interval);print(("Click : %s") % (news["title_label"]))
	
		#1-表示从第一个layout开始学习(滑动后,新的一页,将从第二个layout开始学习)
		#layout_count-表示共学习30篇
		# need_share-表示是否需要转发到微信
		#1-表示index,现在正在学习的是第几篇
		sequence_watch_vedios_news(d,config,"news",1,int(news["layout_count"]), change_boolean(news["need_share"]), 1,share_target)
	message = hehe_common.get_time() + "------------结束-------------"
	send_messages_by_wechat(d,config,message)
	d.implicitly_wait(25)
Example #7
0
def order_a_dinner(username, secret):
    config = hehe_common.common_config()
    firefox_path = config['global_cfg']['firefox_path']
    #driver = webdriver.Firefox('/home/hehezhou/workspace/asr/programfile/firefox')
    driver = webdriver.Firefox(firefox_path)
    url = r'http://10.1.50.42:8888/'
    driver.get(url)
    #print(driver.title)
    print("===============================")
    print(("订餐系统欢迎您 (%s)") % (username))
    print("===============================")

    driver.find_element_by_xpath("//*[@href='/auth/login']").click()
    time.sleep(0.2)
    driver.find_element_by_name('email').send_keys(username)
    driver.find_element_by_name("password").send_keys(secret)
    driver.find_element_by_name("submit").click()
    time.sleep(0.2)
    driver.find_element_by_xpath("//*[@href='/auth/ordering_D']").click()
    print("%s---已为账户%s订餐" % (hehe_common.get_time(), username))
    driver.quit()
Example #8
0
def every_day_operation():
    global share_target
    print(("================= (%s) enter =================") %
          (hehe_common.get_time()))
Example #9
0
def shareToFriends(d, config, is_shipin, need_share, timetotal, index, lists):
    interval = int(config["time_interval"]["operate"])
    message_context = str(title_bar["title_label"])

    comment_len = len(config["comment"])
    pick_on_index = round(random.uniform(1, comment_len)) - 1
    sendMessage = config["comment"][pick_on_index]
    try:
        if need_share == True:
            for dict in lists:
                if "shipin" in dict and is_shipin != "shipin":
                    continue
                if "news" in dict and is_shipin != "news":
                    continue

                if "click" in dict:
                    print(dict["click"])
                    d.click(float(dict["click"][0]), float(dict["click"][1]))
                    print_and_delay_by_dict(config, dict)

                if "send_key_text" in dict:
                    print(dict["send_key_text"])
                    print(sendMessage)
                    d(text=dict["send_key_text"]).send_keys(sendMessage)
                    d(text="发布").click()
                    print_and_delay_by_dict(config, dict)

                if "resourceId" in dict:
                    print(dict["resourceId"])
                    if d(resourceId=dict["resourceId"]).exists:
                        d(resourceId=dict["resourceId"]).click()
                        print_and_delay_by_dict(config, dict)

                if "xpath_conditition" in dict:
                    print(dict["xpath_conditition"])
                    print(dict["xpath_command"])
                    if d.xpath(dict["xpath_conditition"]).exists:
                        d.xpath(dict["xpath_command"]).click()
                        print_and_delay_by_dict(config, dict)

                if "x_path" in dict:
                    print(dict["x_path"])
                    if d.xpath(dict["x_path"]).exists:
                        d.xpath(dict["x_path"]).click()
                        print_and_delay_by_dict(config, dict)

        message_header = hehe_common.get_time() + "--第" + str(index) + "篇("
        message_tail = ")学习成功, 学习时间约:" + timetotal + "s"
        message = message_header + message_context + message_tail
        print(message)
        send_messages_by_wechat(d, config, message)
    except:
        message_header = hehe_common.get_time() + "--第" + str(index) + "篇("
        message_tail = ")学习失败"
        message = message_header + message_context + message_tail
        print(message)
        send_messages_by_wechat(d, config, message)

        try:
            if is_shipin == "shipin":
                reinitialize_for_watch_videos(d, config)
            else:
                reinitialize_for_watch_news(d, config)
            str_path = '//android.widget.ListView/android.widget.FrameLayout[2]'
            d.xpath(str_path).click()
            delay_random(interval)

        except:
            pass