我正在测试我的应用程序,作为当前方案的一部分,我已经在android
内创建了多个文件。我要在完成测试后删除这些文件。
因此,appium具有pull file
,push file
和pull folder
,但是我看不到delete file
的任何文档。
在Windows文件浏览器中,我的设备在This PC\P00A\Internal shared storage
下可见,在此路径下,我可以看到我的所有文件夹,但使用python
却无法以某种方式到达此路径。
有什么建议吗?
答案 0 :(得分:0)
尝试使用adb:
adb shell rm <file>
答案 1 :(得分:0)
从android中删除文件的命令是这样的:
adb shell rm </sdcard/test.txt>
您可能要在终端上的cmd上尝试该命令,直到您使它起作用为止,因为Android上的文件路径非常棘手。
您将可以在此链接中找到(rm)命令的所有选项: http://adbshell.com/commands/adb-shell-rm
答案 2 :(得分:0)
您可以使用mobile:shell command在移动设备上执行任意操作:
result = driver.execute_script('mobile: shell', {
'command': 'rm',
'args': ['/sdcard/file.txt'],
'includeStderr': True,
'timeout': 5000
})
print(result['stdout'])
使用Run Command (adb)上的Appium SeeTest Extensions速记可能会更容易:
seetest.run(("adb shell rm /sdcard/file.txt");