随笔- 310  文章- 1  评论- 0  阅读- 85841 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#coding:utf-8
#pip install pyyaml
import yaml
import os
 
desired_caps = {
                       'platformName': 'Android',
 
                       'platformVersion': '7.0',
 
                       'deviceName': 'ASRNW1111111111',
 
                       'appPackage': 'com.tencent.com',
 
                       'appActivity': 'ui.LauncherUI',
 
                       'automationName': 'Uiautomator2',
 
                       'unicodeKeyboard': True,
 
                       'resetKeyboard': True,
 
                       'noReset': True,
 
                       'chromeOptions': {'androidProcess': 'com.tencent.com'}
 
}
 
curpath = os.path.dirname(os.path.realpath(__file__))
 
yamlpath = os.path.join(curpath, "cfgyaml.yaml")
 
 
def read_yml(file=yamlpath):
    with open(file, 'r', encoding='utf-8') as f:
        return yaml.load(f.read(), Loader=yaml.FullLoader)
 
def write_yml(file,data):
    with open(file, 'w', encoding="utf-8") as f:
        yaml.dump(data=data, stream=f,allow_unicode=True)
 
 
 
             
 
 
if __name__ == "__main__":
    write_yml(yamlpath,desired_caps)
    result = read_yml()
    print(result)
    #{'appActivity': 'ui.LauncherUI', 'appPackage': 'com.tencent.com', 'automationName': 'Uiautomator2', 'chromeOptions': {'androidProcess': 'com.tencent.com'}, 'deviceName': 'ASRNW1111111111', 'noReset': True, 'platformName': 'Android', 'platformVersion': '7.0', 'resetKeyboard': True, 'unicodeKeyboard': True}
    

  

 posted on   boye169  阅读(21)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
历史上的今天:
2021-05-30 linux连接工具MobaXterm下载及使用
点击右上角即可分享
微信分享提示