Xamarin UI测试 | adb cmd to open mobile phone Internal storage via mobile screen (不是通过adb pull命令拉取数据)

Xamarin UITest | adb cmd to open mobile phone Internal storage via mobile screen (not through adb pull command and pull the data )

我们的应用程序基于 xamarin 表单构建,我正在执行 xamarin UITest 以自动化 android 本机应用程序。

场景:在验证期间,我必须导航到 Phone 的内部存储位置,我必须在其中打开一个文件夹(在此步骤之前创建) -> 打开 sysId.txt 文件 -> 验证文件的内容。

我的方法:我尝试了很多方法来找到一个合适的命令来通过手机屏幕打开内部存储但是我找不到除了使用手机屏幕坐标之外的任何解决方案( PFB)

以下命令用于从主屏幕导航到我的 txt 文件位置(这些步骤仅适用于 MotoG8_Plus):

打开文件夹adb shell monkey -p com.google.android.apps.nbu.files -v 10

在文件夹中向下滑动:adb shell 输入滑动 500 1000 300 300

点击内部存储:adb shell 输入点击 650 1800

点击 iSpiro 文件夹:adb shell 输入点击 1000 1150

点击 sysId.txt : adb shell input tap 400 400

点击 HTML 查看器:adb shell 输入点击 300 2000

注意:以上命令仅适用于 Motog8_Plus 移动设备,因为内部存储路径和点击坐标是该设备特定的,但我正在寻找打开内部存储文件夹的通用解决方案(通过移动屏幕)并按名称单击文件夹(例如使用 adb 命令按名称 xyz 单击 xyz 文件夹)

提前感谢您的帮助!

因为我的测试应该 运行 在其他设备上我想安装(material_files.apk)一个新的文件浏览器(删除 google 个文件)然后

  1. 打开内部存储:

    adb shell am start --user 0 -a android.intent.action.VIEW -d file://storage/sdcard/" -t resource/folder
    
  2. 打开 ABC 文件夹:

    adb shell am start --user 0 -a android.intent.action.VIEW -d file://storage/sdcard/ABC" -t resource/folder
    
  3. 打开文本文件(XYZ.txt):

    adb shell am start --user 0 -a android.intent.action.VIEW -d file://storage/sdcard/ABC/XYZ.txt -t text/plain