def del_file(path):
for elm in Path(path).glob('*'):
elm.unlink() if elm.is_file() else shutil.rmtree(elm)
def wifi_and_data_disable(self):
os.system("adb shell svc wifi disable") # 关闭WiFi
os.system("adb shell svc data disable") # 关闭流量
def wifi_able(self):
os.system("adb shell svc wifi enable")
def read_excelToList_phone(self):
return xfile.read( "../userLoginData1.xls").excel_to_dict(sheet=0)
def read_excelToList_email(self):
return xfile.read(config.GET_BACE_PATH+ "/userLoginData1.xls").excel_to_dict(sheet=1)
def driver_setup():
desi_caps = dict()
desi_caps['platformName'] = 'Android'
desi_caps['platformVersion'] = '9'
desi_caps['deviceName'] = '19052315134267'
desi_caps['unicodeKeyboard'] = True
# desi_caps['resetKeyboard'] = True
desi_caps['automationName'] = 'UIAutomator2'
# 包名
desi_caps['appPackage'] = 'com.waterworld.haifit'
# 界面名
desi_caps['appActivity'] = '.ui.module.account.SplashActivity'
return desi_caps
### config.py:
import os
from xToolkit import xfile
#设置项目环境域名
path_user = r’D:\AppniumPro1\image_user’ # 输入文件夹地址
agreement = “com.waterworld.haifit:id/tv_dialog_agreement_right”
send_name = “youke_test”
defult_nichen = “HaFit”
test_nichen = defult_nichen +“_test”
confirm =“确认”
permit = “允许”
visitor_login = “游客登录”
finish = “com.waterworld.haifit:id/mbtn_complete”
mine = “我的”
log_out = “退出登录”
visible = “com.waterworld.haifit:id/cb_login_password_is_visible”
tap_the_phone = “com.waterworld.haifit:id/tv_title_left”
tap_emali = “com.waterworld.haifit:id/tv_title_right”
account_phone = “com.waterworld.haifit:id/et_account_phone”
account_email = “com.waterworld.haifit:id/et_account_email”
input_psw = “com.waterworld.haifit:id/medt_input_psw”
#账号登录按钮
enter = “com.waterworld.haifit:id/mbtn_login”
#获取根目录,参数__file__指的是当前文件的目录,config位于根目录下,所以返回值就是根目录(当前文件的目录)
GET_BACE_PATH = os.path.dirname(file)
print(GET_BACE_PATH)
print(“------”)
phone_list = xfile.read(GET_BACE_PATH + “/userLoginData1.xls”).excel_to_dict(sheet=0)
print(phone_list)
#### login.py:
import time
import config
from base.base_page import BasePage
class LoginPage(BasePage):
#同意
def agreement(self):
time.sleep(15)
self.find_el_by_id(config.agreement).click()
def confirm(self):
self.find_el_by_uiautomator_text(config.confirm).click()
def permit(self):
self.find_el_by_uiautomator_text(config.permit).click()
def find_el_by_id_and_click(self,el_id,time =15, frequency =0.1):
self.find_el_by_id(el_id,time,frequency).click()
def find_el_by_uiautomator_text_click(self, el_text ,time =18, frequency =0.01):
self.find_el_by_uiautomator_text(el_text,time,frequency).click()
def find_el_by_id_sendkeys(self,id,data,time =15, frequency =0.1):
self.find_el_by_id(id,time =15, frequency =0.1).send_keys(data)
#---------退出登录–
def loginoff(self):
print(“进入退出登录–”)
self.find_el_by_uiautomator_text_click(config.mine)
self.find_el_by_uiautomator_text_click(config.log_out)
self.confirm()
print(“—登录状态退出”)
#------------------------------进入账号登录环节-----------------------------------------
def input_testdata(self,data_list,user_id,password_id):
# 可见密码
print(“开始测了–11”)
self.find_el_by_id_and_click(config.visible)
print(“密码已经设置为可见–”)
for i in data_list:
text_result = i.get(“预期结果”)
print(“1`1```1”)
self.find_el_by_id_sendkeys(user_id, i.get(“账号”))
time.sleep(1)
print(“–账号已输入–”)
self.find_el_by_id_sendkeys(password_id, i.get(“密码”))
time.sleep(1)
print(“–密码已输入–”)
if i.get("预期结果") == "不可点" or i.get("预期结果") == "登录成功":
print("是不可点或者登录成功")
self.find_el_by_id_and_click(config.enter)
time.sleep(4)
self.get_screenshot_as_file("../image_user/%s%s.png", text_result)
time.sleep(2)
else:
# text模糊定位
print("-----------------登录错误提示:")
self.find_el_by_id_and_click(config.enter)
print("已经点击登录了 -----")
element = self.find_toast(text_result)
self.get_screenshot_as_file("../image_user/%s%s .png", element.text)
if element.text == text_result:
print("%s,结果一致" % i.get("预期结果"))
time.sleep(2)
#---------组合业务01--游客登录-----------
def do_visitor_login(self):
self.agreement()
self.wifi_and_data_disable()
print("已关闭WiFi和流量")
# self.visitor_login()
self.find_el_by_uiautomator_text_click(config.visitor_login)
print("已选择游客登录")
self.confirm()
self.permit()
self.find_el_by_id_and_click(config.finish)
self.loginoff()
time.sleep(1)
print("已退出登录--")
#----------组合业务02----用户登录---******------------------
def do_user_login(self):
self.wifi_able()
print("开始test了,先选择手机登录:")
self.find_el_by_id_and_click(config.tap_the_phone)
print("已切换到手机登录-------------")
self.input_testdata(self.read_excelToList_phone() ,config.account_phone, config.input_psw)
self.loginoff()
print("$$$$$$切换到邮箱$$$$$$$$")
self.find_el_by_id_and_click(config.tap_emali)
print("-----------进入邮箱登录")
self.input_testdata(self.read_excelToList_email() ,config.account_email , config.input_psw)
self.loginoff()
time.sleep(1)
print("+++==============登录模块测试完毕==============+++")
#### test\_login.py:
**自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。**
**深知大多数Python工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!**
**因此收集整理了一份《2024年Python开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。**
![img](https://img-blog.csdnimg.cn/img_convert/2879224bbf76a8acddf0c1c70d6c08cf.png)
![img](https://img-blog.csdnimg.cn/img_convert/6f2fd2c9820ca0aae14e5ffdd9722dc4.png)
![](https://img-blog.csdnimg.cn/img_convert/46506ae54be168b93cf63939786134ca.png)
![](https://img-blog.csdnimg.cn/img_convert/252731a671c1fb70aad5355a2c5eeff0.png)
![](https://img-blog.csdnimg.cn/img_convert/6c361282296f86381401c05e862fe4e9.png)
![](https://img-blog.csdnimg.cn/img_convert/9f49b566129f47b8a67243c1008edf79.png)
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Python开发知识点,真正体系化!**
**由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新**
**如果你觉得这些内容对你有帮助,可以添加V获取:vip1024c (备注Python)**
![img](https://img-blog.csdnimg.cn/img_convert/080b5454ac4e721a9ffe0a12b4f2738a.png)
### 一、Python所有方向的学习路线
Python所有方向路线就是把Python常用的技术点做整理,形成各个领域的知识点汇总,它的用处就在于,你可以按照上面的知识点去找对应的学习资源,保证自己学得较为全面。
![](https://img-blog.csdnimg.cn/img_convert/9f49b566129f47b8a67243c1008edf79.png)
### 二、学习软件
工欲善其事必先利其器。学习Python常用的开发软件都在这里了,给大家节省了很多时间。
![](https://img-blog.csdnimg.cn/img_convert/8c4513c1a906b72cbf93031e6781512b.png)
### 三、入门学习视频
我们在看视频学习的时候,不能光动眼动脑不动手,比较科学的学习方法是在理解之后运用它们,这时候练手项目就很适合了。
![](https://img-blog.csdnimg.cn/afc935d834c5452090670f48eda180e0.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA56iL5bqP5aqb56eD56eD,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)
它们,这时候练手项目就很适合了。
![](https://img-blog.csdnimg.cn/afc935d834c5452090670f48eda180e0.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA56iL5bqP5aqb56eD56eD,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)