python3基于uiautomator2实现钉钉自动打卡Word格式.docx

上传人:b****1 文档编号:4039961 上传时间:2023-05-02 格式:DOCX 页数:11 大小:56.01KB
下载 相关 举报
python3基于uiautomator2实现钉钉自动打卡Word格式.docx_第1页
第1页 / 共11页
python3基于uiautomator2实现钉钉自动打卡Word格式.docx_第2页
第2页 / 共11页
python3基于uiautomator2实现钉钉自动打卡Word格式.docx_第3页
第3页 / 共11页
python3基于uiautomator2实现钉钉自动打卡Word格式.docx_第4页
第4页 / 共11页
python3基于uiautomator2实现钉钉自动打卡Word格式.docx_第5页
第5页 / 共11页
python3基于uiautomator2实现钉钉自动打卡Word格式.docx_第6页
第6页 / 共11页
python3基于uiautomator2实现钉钉自动打卡Word格式.docx_第7页
第7页 / 共11页
python3基于uiautomator2实现钉钉自动打卡Word格式.docx_第8页
第8页 / 共11页
python3基于uiautomator2实现钉钉自动打卡Word格式.docx_第9页
第9页 / 共11页
python3基于uiautomator2实现钉钉自动打卡Word格式.docx_第10页
第10页 / 共11页
python3基于uiautomator2实现钉钉自动打卡Word格式.docx_第11页
第11页 / 共11页
亲,该文档总共11页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

python3基于uiautomator2实现钉钉自动打卡Word格式.docx

《python3基于uiautomator2实现钉钉自动打卡Word格式.docx》由会员分享,可在线阅读,更多相关《python3基于uiautomator2实现钉钉自动打卡Word格式.docx(11页珍藏版)》请在冰点文库上搜索。

python3基于uiautomator2实现钉钉自动打卡Word格式.docx

#-*-coding:

utf-8-*-

#@Time:

2019/06/1116:

34

#@Author:

huangpeng

#@Site:

#@File:

AutoClock.py

#@Software:

PyCharm

importunittest

importtime

importsys

importuiautomator2asu2

importlogging

logging.basicConfig(level=logging.INFO,format='

%(asctime)s-%(name)s-%(levelname)s-%(message)s'

logger=logging.getLogger(__name__)

d=u2.connect()

#d=u2.connect('

192.168.1.239'

#打开文本文件

fp=open('

config.txt'

'

r'

#使用readlines读取

lines=fp.readlines()

config={}

forlineinlines:

#将读取的每行内容过滤掉换行符,如果不加这个条件,输入的内容中将会添加换行符\n

line=line.strip('

\n'

ss=line.split('

='

)#将每行内容根据=分割

config[ss[0]]=ss[1]

fp.close()

————————————————

classTest(unittest.TestCase):

defsetUp(self):

self.watcherson()

print('

d.watchers'

print("

----------SetUp-----\n"

deftearDown(self):

d.watchers.remove()

-----------TearDown----\n"

defwatcherson(self):

d.watcher(u'

注意'

).when(text=u'

你在此次选择后可以到“手机管理-权限管理”中修改此项设置'

).click(text=u'

允许'

className='

android.widget.Button'

resourceId='

android:

id/button1'

无响应'

关闭应用'

d.watchers.run()

pass

deftest_autoclockout(self):

#下班打卡

logger.info("

检查时间是否到下班时间"

whileTrue:

time1=config["

下班起始时间"

]#起始下班时间(启动ddapk时间)

time2=config["

下班终止时间"

]#终止时间

now1=time.strftime("

%H%M%S"

)#一定要在while循环中才会实时更新为当前时间

ifint(time2)>

int(now1)>

int(time1):

#定时执行app

到下班时间"

self.test_autoclock()#进入dd应用,进行极速打卡

time.sleep

(1)

self.test_WeChatMsgsnd()#打开微信分享打卡截图

break

deftest_autoclockin(self):

#上班打卡

检查时间是否到上班时间"

time1=config["

上班起始时间"

time2=config["

上班终止时间"

)#一定要在while循环中才会实时更新为当前时间

ifint(time2)>

int(now1)>

int(time1):

#定时执行app

到上班时间"

进入dd"

self.test_WeChatMsgsnd()#打开微信分享打卡截图

deftest_WeChatMsgsnd(self):

time.sleep(3)

self.test_lock()

打开dd"

d.app_start("

com.alibaba.android.rimet"

)#打开dd

time.sleep(5)

截图"

d.screenshot("

Screenshot.jpg"

time.sleep

(2)

d.push("

"

/sdcard/0pics/"

退出dd"

d.app_stop("

d.press("

home"

打开文件管理器"

com.qiku.android.filebrowser"

检查是否在文件夹初始界面"

ifd(resourceId="

com.qiku.android.filebrowser:

id/storage_name"

).exists:

在文件夹初始界面,进入文件夹"

d(resourceId="

id/storage_arrows"

).click()

进入保存图片文件夹"

id/file_name"

长按图片"

d.long_click(0.348,0.219)

分享"

d(text=u"

选分享对象"

发送给朋友"

选择朋友"

com.tencent.mm:

id/b98"

time.sleep(0.5)

).clear_text()

).set_text(config["

自己微信大号名称"

])

id/qm"

点击发送"

id/b00"

time.sleep(7)

息屏"

d.screen_off()#息屏

else:

不在文件夹初始界面,返回继续检查是否在初始界面"

back"

deftest_autoclock(self):

#进入dd应用,进行极速打卡

检查解手机屏幕锁"

self.test_lock()#判断是否需要屏幕解锁

判断是否在手机初始桌面"

ifd(text=u"

拨号"

).exists():

#判断是否在手机初始桌面

在手机初始桌面"

判断是否需要登录"

com.alibaba.android.rimet:

id/btn_next"

#判断是否需要登录

需要登录"

self.test_login()#执行登录dd账户

登录成功"

等待30秒极速打卡时间"

time.sleep(30)

)#退出dd

forcountinlist(range(1,3)):

进入dd,执行极速打卡"

)#退出dd

不需要登录,执行极速打卡"

不在手机初始桌面,返回继续检测是否在初始桌面"

deftest_login(self):

#登录dd账号

输入账号"

id/et_phone_input"

).clear_text()#这里是清除指定元素的内容

钉钉账号"

])#这里是在指定元素中输入dd账号

输入密码"

id/et_pwd_login"

钉钉密码"

])#这里是在指定元素中输入dd密码#

登录"

deftest_lock(self):

#解锁手机屏幕

d.screen_on()

判断手机是否在锁屏状态"

com.android.systemui:

id/notification_stack_scroller"

#判断手机是否在锁屏状态

锁屏状态,执行解锁"

d.swipe_points([(0.485,0.708),(0.481,0.286)],0.05)#滑动解锁界面

判断是否存在图案锁"

id/lockPatternView"

#判断是否存在图案锁

存在,需要解图案锁"

d.swipe_points([(0.777,0.539),(0.509,0.691),(0.777,0.694),(0.512,0.853),],0.05)#解九宫图案锁(需要修改自己的图案锁坐标)

不存在,滑动解锁成功"

手机未锁屏不用解锁"

if__name__=='

__main__'

:

Test=Test()

Test.test_autoclockout()

Test.test_autoclockin()

3.2备注:

AutoClock.py是使用360N5手机适配,其他手机可能需要轻微的修改

可以支持解图案锁,但要根据实际手机情况修改图案坐标位置,也可以不设置图案锁

需开启钉钉极速打卡功能,开启极速打卡、开启极速打卡、开启极速打卡……

将AutoClock.py、start_AutoClock.ba和config.txt放在同一个目录下

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2