class XXX():
logging.basicConfig(level=logging.DEBUG, filename="D:/XXX/XXX/Log/LoginLOG.log",
format="%(asctime)s%(filename)s [line:%(lineno)d] %(levelname)s %(message)s")
with open('D:/XXX/XXX/Config/desired_caps.yaml', 'r', encoding='UTF-8') as file:
data = yaml.load(file, Loader=yaml.FullLoader)
# 把YAML中的字段值一一存放到desired_caps
desired_caps = {}
desired_caps['platformName'] = data['platformName']
desired_caps['platformVersion'] = data['platformVersion']
desired_caps['deviceName'] = data['deviceName']
# base_dir = os.path.dirname(os.path.dirname(__file__))
# app_path = os.path.join(base_dir, 'app', data['appname'])
# desired_caps['app'] = app_path
desired_caps['udid'] = data['udid']
desired_caps['appPackage'] = data['appPackage']
desired_caps['appActivity'] = data['appActivity']
desired_caps['noReset'] = data['noReset']
# 启动远程端口服务
driver = webdriver.Remote('http://' + str(data['ip']) + ':' + str(data['port']) + '/wd/hub', desired_caps)
driver.implicitly_wait(5)
@allure.feature('XXX_00')
@allure.story('test_story_00')
@allure.severity('critical')
def XXX_00(self):
"""
测试用例1:登录
:return:
"""
gp = GuidePage(self.driver)
gp.click_enter()
print("点击立即体验,成功进入")
lgp = LoginPage(self.driver)
time.sleep(2)
# 点击同意授权
lgp.agree()
# 输入帐号密码,并登录
f = open("D:/XXX/XXX/Config/account.txt")
lines = f.readlines()
for line in lines:
# 替换掉每多余符号
line = line.replace("\"", "").replace("\n", "")
lineList = line.split(",")
account1 = lineList[0]
account2 = lineList[1]
lgp.input(account1, account2)
lgp.login()
print("登录成功")
appium -a 127.0.0.1 -p 4723 -U 127.0.0.1:62001 --session-override
打开夜神模拟器,打开设置,调成手机模式,初次进入的话,进入设置,点击版本号 5 次,可以激活使用开发者模式,进入后打开 USB 调试功能。
打开文件资源管理器,进入夜神模拟器的安装位置,在地址栏输入 cmd,回车,会打开 cmd 窗口,进入的路径就是夜神模拟器的安装位置。我的默认安装位置:C:\Program Files (x86)\Nox\bin。
输入 nox_adb.exe connect 127.0.0.1:62001 即可以连接到 adb,或者是 adb connect 127.0.0.1:62001。
切换到 doc 输入 adb devices,可以显示到连接上的设备。