我的 APP 有这样一个问题,用户首次启动的时候会显示欢迎页,第二次启动就不会有欢迎页,是否是第一次启动在这个 app 的安装目录中有个 xml 文件记录,现在我应该怎样去读取到这个 xml 文件呢?
我的源代码是:
from appium import webdriver
import time
import os
PATH = lambda p: os.path.abspath(os.path.join(os.path.dirname(__file__), p))
desired_caps = {}
desired_caps['platformName'] = 'android'
desired_caps['browserName'] = ''
desired_caps['platformVersion'] = '4.2.2'
desired_caps['deviceName'] = 'Android Emulator'
desired_caps['app'] = PATH('E:\Test\sdk\platform-tools\LoadActivity.apk')
desired_caps['app-package'] = 'com.novunda.tcaapp'
desired_caps['app-activity'] = 'com.novunda.controller.load.WelcomeActivity'
dr = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
dr.find_element_by_class_name('android.widget.RelativeLayout')
dr.pull_file('_data/data/com.novunda.tcaapp/shared_prefs/insatlldata.xml')
运行的时候报错:
Traceback (most recent call last):
File "E:/apptest/android ui test.py", line 17, in <module>
dr.pull_file('_data/data/com.novunda.tcaapp/shared_prefs/insatlldata.xml')
File "D:\Python27\lib\site-packages\appium\webdriver\webdriver.py", line 432, in pull_file
return self.execute(Command.PULL_FILE, data)['value']
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 173, in execute
self.error_handler.check_response(response)
File "D:\Python27\lib\site-packages\appium\webdriver\errorhandler.py", line 29, in check_response
raise wde
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. (Original error: Command failed: remote object '_data/data/com.novunda.tcaapp/shared_prefs/insatlldata.xml' does not exist)
但是我用 adb 命令又是能找到这个文件的: