测试人社区

【Appium的Capabilities配置问题】配置dontStopAppOnReset就会启动报错

配置代码:

from time import sleep

from appium import webdriver


class TestApp:

    def setup_class(self):
        """
        启动app
        :return:
        """
        caps = {}
        caps["platformName"] = "Android"
        caps["platformVersions"] = "6.0"
        caps["deviceName"] = "127.0.0.1:62001"
        caps["appPackage"] = "com.xueqiu.android"
        caps["appActivity"] = ".view.WelcomeActivityAlias"
        caps["noReset"] = "true"
        caps["dontStopAppOnReset"] = "true"
        caps["skipDeviceInitialization"] = "true"
        # caps["browserName"] = "Browser"
        caps["chromedriverExecutable"] = r"D:\Android\chromedriver.exe"
        self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)
        self.driver.implicitly_wait(5)

    def teardown_class(self):
        pass

    def test_app(self):
        print("==========")
        print(self.driver.contexts)
        self.driver.find_element_by_xpath("//*[@resource-id='com.xueqiu.android:id/tab_name' and @text='交易']").click()
        sleep(5)
        print(self.driver.contexts)
        self.driver.find_element_by_xpath("//*[@class='android.view.View' and @text='免费领']").click()

报错信息:

相反,如果注释掉dontStopAppOnReset就会正常启动运行,很奇怪

先这样吧,夜深模拟器才有这种情况,改用mumu是好的。