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()
def taobao(username, secret): config = hehe_common.common_config() firefox_path = config['global_cfg']['firefox_path'] driver = webdriver.Firefox(firefox_path) url = r'https://www.taobao.com/' driver.get(url) print(driver.title) driver.find_element_by_xpath("//a[contains(text(),'亲,请登录')]").click() driver.find_element_by_xpath("//i[@id='J_Quick2Static']").click() time.sleep(0.5) driver.find_element_by_xpath("//input[@id='TPL_username_1']").send_keys( username) driver.find_element_by_xpath("//input[@id='TPL_password_1']").send_keys( secret) time.sleep(0.2) index_y = 200 while True: #time.sleep(2) try: taobao_verify(driver, index_y) index_y += 50 except: print("try----") break time.sleep(2) driver.find_element_by_xpath("//button[@id='J_SubmitStatic']").click()
def work_every_day(): config = hehe_common.common_config() for list in config['order_list']: order_a_dinner(list[0], list[1]) jingdong("13262563857", "xxxxxx") jingdong("13062786153", "xxxxxx")
def trigger_adroid9_ci(idList, projectName): config = hehe_common.common_config() Jenkins_USER = config['secret']['Jekins_username'] Jenkins_PASSWD = config['secret']['Jekins_passwd'] firefox_path = config['global_cfg']['firefox_path'] gerritid_list = idList driver = webdriver.Firefox(firefox_path) url = r'http://build.asrmicro.com/view/Android9.0/job/adroid9.0_ci/' driver.get(url) print(driver.title) driver.find_element_by_class_name("login").click() #点击右上角login driver.find_element_by_name('j_username').send_keys(Jenkins_USER) driver.find_element_by_name("j_password").send_keys(Jenkins_PASSWD) driver.find_element_by_id('yui-gen1-button').click() #点击登录 driver.find_element_by_xpath( "//*[@href='/view/Android9.0/job/adroid9.0_ci/build?delay=0sec']" ).click() #点击 Build with Parameters gerritid = driver.find_element_by_class_name('setting-input').send_keys( gerritid_list) #输入GERRIT_IDS if projectName == "aquilac_phone-userdebug": print('Nothing to do') elif projectName == "aquilac_phonegms-userdebug": driver.find_element_by_name("parameter").find_element_by_xpath( "//*[@value='adroid9.0/aquilac_phone-userdebug']").click( ) #取消默认的aquilac_phone-userdebug driver.find_element_by_name("parameter").find_element_by_xpath( "//*[@value='adroid9.0/aquilac_phonegms-userdebug']").click( ) #选中aquilac_phonegms-userdebug else: print('Nothing to do') js3 = "window.scrollTo(0,600)" # 滑动600像素 driver.execute_script(js3) time.sleep(2) checkboxs = driver.find_elements_by_xpath( ".//*[@type='checkbox']") # 勾上OTA、clean_all复选框 for i in checkboxs: i.click() driver.find_element_by_id('yui-gen1-button').click() #点击build按钮 driver.find_element_by_xpath("//input[@placeholder='find']").send_keys( TRIGGER_USER + Keys.ENTER) time.sleep(1) #搜索ZhouHehe触发的jenkins的ID buildID = driver.find_elements_by_xpath( "//*[@update-parent-class='.build-row']")[0] buildNum = buildID.text.split( '#')[1].strip() # buildID.text是提取出来的build NO,如 : #3335 print(buildNum) buildID.click() print(url + buildNum) #webcontext = urllib.request.urlopen(url + buildNum).read() #print(webcontext) driver.quit() return url + buildNum
def send_a_mail(receiver_list, copy_list, title_text, context_text): config = hehe_common.common_config() Email_USER_NAME = config['secret']['Mail_username'] Email_PASSWD = config['secret']['Mail_passwd'] firefox_path = config['global_cfg']['firefox_path'] driver = webdriver.Firefox(firefox_path) url = r'https://mail.asrmicro.com' driver.get(url) print(driver.title) time.sleep(2) #这里必须加 driver.find_element_by_name('username').send_keys(Email_USER_NAME) driver.find_element_by_name("password").send_keys(Email_PASSWD) driver.find_element_by_class_name('signinbutton').click() time.sleep(2) #点击登录 driver.find_element_by_xpath(".//*[@id='_ariaId_35']").click() #点击新建邮件 driver.find_element_by_xpath( "//*[@aria-label='发送收件人。请输入您的联系人列表中的电子邮件地址或姓名。']").send_keys( receiver_list) #收件人 driver.find_element_by_xpath( "//*[@aria-label='抄送收件人。请输入您的联系人列表中的电子邮件地址或姓名。']").send_keys( copy_list) #抄送 driver.find_element_by_class_name( '_f_ql._f_rl.textbox.allowTextSelection.placeholderText').send_keys( title_text) #邮件主题 click_locxy(driver, 650, 490, True) time.sleep(2) #这里sleep必须加 driver.switch_to.active_element.send_keys(context_text) time.sleep(2) #邮件正文 driver.find_element_by_xpath("//*[@aria-label='发送']").click() driver.quit()
def every_hour_excute(): config = hehe_common.common_config() ############## (zhifubao : 蚂蚁森林) ############### zhifubaoConfig = config["zhifubao"] zhifubaoList = config["zhifubao"]["zhifubao_account"] for zfb in zhifubaoList: zhifubao(zfb[0], zfb[1], int(zfb[2]))
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
def every_day_excute(): config = hehe_common.common_config() ############## (qq登录5分钟、qq四国军棋领金币) ############### taobaoConfig = config["taobao"] taobaoList = config["taobao"]["taobao_account"] for tb in taobaoList: taobao(tb[0], tb[1]) ############## (qq登录5分钟、qq四国军棋领金币) ############### qqConfig = config["qq"] qqList = config["qq"]["qq_account"] for qq in qqList: qq_login(qq[0], qq[1], qqConfig["login_time"])
def xuexiqiangguo(username, passwd, name): config = hehe_common.common_config() d = u2.connect() d.app_stop("cn.xuexi.android") d.app_clear('cn.xuexi.android') d.app_start("cn.xuexi.android") delay_random(5) 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) #点击登录 time.sleep(8) delay_random(4) wait_xpath_element_click(d, "//*[@text='我的']", 30) delay_random(2) wait_xpath_element_click(d, "//*[@text='学习积分']", 10) delay_random(2) #点击学习积分 wait_xpath_element_appear(d, "//*[@text='积分明细']", 10) delay_random(2) d.press("back") delay_random(2) wait_xpath_element_appear(d, "//*[@text='学习积分']", 10) delay_random(2) d.press("back") delay_random(2) watch_all_wenzhang_title(d) wait_xpath_element_click(d, "//*[@text='电视台']", 30) delay_random(2) watch_all_shipin_title(d) d.implicitly_wait(25) time.sleep(5) d.app_stop("cn.xuexi.android") d.app_clear('cn.xuexi.android') d.screen_off()
def test(): global share_target share_target = "weixin" config = hehe_common.common_config() d = u2.connect() interval = int(config["time_interval"]["operate"]) #watch_videos(d,config) #watch_news(d,config) #sequence_watch_vedios_news(d,config,"news",1,30,False,1) global title_bar title_bar = { "title": "tuijian", "layout_count": "5", "need_share": "True", "title_label": "推荐" } share_to_friend(d, config, "news", True, "40", 1)
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()
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()
def test(): config = hehe_common.common_config() d = u2.connect() time.sleep(10000)
def daily_order(): config = hehe_common.common_config() for list in config['order_list']: web_operation.order_a_dinner(list[0],list[1])
def test(): d = u2.connect() config = hehe_common.common_config()
def test(): config = hehe_common.common_config() d = u2.connect() interval = int(config["time_interval"]["operate"]) #watch_videos(d,config) watch_news(d,config,"weixin")
############ tash ################# def work_every_day(): config = hehe_common.common_config() for list in config['order_list']: order_a_dinner(list[0], list[1]) jingdong("13262563857", "xxxxxx") jingdong("13062786153", "xxxxxx") if __name__ == '__main__': print(str(sys.argv[0]) + " enter") print("1111111111111") config = hehe_common.common_config() #secret Email_USER_NAME = config['secret']['Mail_username'] Email_PASSWD = config['secret']['Mail_passwd'] Jenkins_USER = config['secret']['Jekins_username'] Jenkins_PASSWD = config['secret']['Jekins_passwd'] OrderDinner_USER = config['secret']['OrderDinner_username'] OrderDinner_PASSWD = config['secret']['OrderDinner_passwd'] #work_every_day() schedule.every().day.at("08:00").do(work_every_day) while True: schedule.run_pending() time.sleep(10)