这里是Appium的示例代码,如果我添加
noReset='true'
,那么应用程序不会启动,测试失败。删除它一切正常。
上下文是在某些测试中,我不想清除应用程序缓存。但这个
noReset
好像坏了,请帮忙。
Appium: 2.5.3
Python: 3.12
Appium-Python-Client: 4.0.0
import unittest
from appium import webdriver
from appium.options.android import UiAutomator2Options
from appium.webdriver.common.appiumby import AppiumBy
capabilities = dict(
platformName='Android',
automationName='uiautomator2',
deviceName='Android',
appPackage='com.android.settings',
appActivity='.Settings',
language='en',
locale='US',
noReset='true' # comment this line, the app could be launched
)
appium_server_url = 'http://localhost:4723'
class TestAppium(unittest.TestCase):
def setUp(self) -> None:
self.driver = webdriver.Remote(appium_server_url, options=UiAutomator2Options().load_capabilities(capabilities))
def tearDown(self) -> None:
if self.driver:
self.driver.quit()
def test_find_battery(self) -> None:
el = self.driver.find_element(by=AppiumBy.XPATH, value='//*[@text="Battery"]')
el.click()
if __name__ == '__main__':
unittest.main()
我认为在自动化操作系统或捆绑应用程序(如设备设置
noReset
)时,您不能使用 fullReset
或 com.android.settings
选项。这没有问题,因为我们不负责测试操作系统附带的应用程序。在所有其他应用程序中,您应该都会遇到这样的问题。