使用Windows电脑进行真机运行,根目录下添加了config.json文件,内容如下:
{
"project_path": "C:\\Users\\wb.chenchunzhi20\\Desktop\\小程序测试包\\测试环境\\V4.2.1测试",
"dev_tool_path": "C:\\Program Files (x86)\\Tencent\\微信web开发者工具\\.cli.bat",
"platform": "Android"
}
first.test.py文件中的代码如下:
import minium
# mini = minium.Minium({
# # 小程序项目目录地址,这里是Windows系统的目录
# "project_path": "C:\\Users\\wb.chenchunzhi20\\Desktop\\小程序测试包\\测试环境\\V4.2.1测试",
# # 开发者工具cli地址,Windows系统就是默认这个路径
# "dev_tool_path": "C:\\Program Files (x86)\\Tencent\\微信web开发者工具\\cli.bat",
# "platform": "Android"
#
# })
import minium
class ExceptionTest(minium.MiniTest):
def test_get_current_page(self):
self.page.get_element('view', inner_text='加入').click()
if __name__ == '__main__':
ExceptionTest().test_get_current_page()
运行first_test.py无法调用微信开发者工具,报错内容如下:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.1.1\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.1.1\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/wb.chenchunzhi20/Desktop/UI自动化/小程序自动化/wechatDemo序自动化/wechatDemo/test/first_test.py", line 22, in <module>
ExceptionTest().test_get_current_page()
File "C:/Users/wb.chenchunzhi20/Desktop/UI自动化/小程序自动化/wechatDemo序自动化/wechatDemo/test/first_test.py", line 18, in test_get_current_page
self.page.get_element('view', inner_text='加入').click()
File "D:\Python3\lib\site-packages\minium-1.0.6-py3.9.egg\minium\framework\assertbase.py", line 346, in __getattribute__
attr = super().__getattribute__(item)
File "D:\Python3\lib\site-packages\minium-1.0.6-py3.9.egg\minium\framework\minitest.py", line 656, in page
return self.mini.app.get_current_page()
AttributeError: 'NoneType' object has no attribute 'app'
将first.test.py上边注释掉的内容打开后,可以正常真机运行,但是依旧会报以下错误:
received async msg: 9dfd40ee-6d1c-4ecf-b234-e7634084aada
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.1.1\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.1.1\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/wb.chenchunzhi20/Desktop/UI自动化/小程序自动化/wechatDemo序自动化/wechatDemo/test/first_test.py", line 22, in <module>
ExceptionTest().test_get_current_page()
File "C:/Users/wb.chenchunzhi20/Desktop/UI自动化/小程序自动化/wechatDemo序自动化/wechatDemo/test/first_test.py", line 18, in test_get_current_page
self.page.get_element('view', inner_text='加入').click()
File "D:\Python3\lib\site-packages\minium-1.0.6-py3.9.egg\minium\framework\assertbase.py", line 346, in __getattribute__
attr = super().__getattribute__(item)
File "D:\Python3\lib\site-packages\minium-1.0.6-py3.9.egg\minium\framework\minitest.py", line 656, in page
return self.mini.app.get_current_page()
AttributeError: 'NoneType' object has no attribute 'app'
这种情况下我想问以下问题:
1.config.json文件如何生效?
2.'NoneType' object has no attribute 'app'这个问题怎么解决?
请参考https://minitest.weixin.qq.com/#/minium/Python/framework/example
同问,出现AttributeError: 'NoneType' object has no attribute 'trigger'是什么原因?如何解决?
配置有问题吧,可以看看官方文档。