首页 > 解决方案 > 如何打开和关闭应用程序并仍然记录每个测试用例?(RobotFramework/AppiumLibrary)

问题描述

我正在尝试使用 AppiumLibrary 设置机器人框架自动化。我想关闭应用程序并在每个测试用例中再次打开它,但无需再次登录。实际上,当我关闭应用程序时,应用程序会重置并要求我再次登录。我只是将“noReset=true”功能放在 Open Application 上,但这并不能解决我的问题。有人知道该怎么做吗?

***Settings***
Library     AppiumLibrary

***Keywords***
Start Session
    Set Appium Timeout  10
    Open Application    http://localhost:4723/wd/hub
    ...                 automationName=UiAutomator2
    ...                 platformName=Android
    ...                 deviceName=emulator-5554
    ...                 appPackage=br.com.app.app
    ...                 appActivity=.MainActivity
    ...                 autoGrantPermissions=true
    ...                 noReset=true
    Sleep               5

Start app
    Wait Until Page Contains               Hello

Close Session
    Capture Page Screenshot
    Close Application                      noReset=true

Close Application
    Capture Page Screenshot
    Quit Application   

Launch Application
    Open Application                     http://localhost:4723/wd/hub
    ...                                  automationName=UiAutomator2
    ...                                  platformName=Android
    ...                                  deviceName=emulator-5554
    ...                                  appPackage=br.com.app.app
    ...                                  appActivity=.MainActivity
    ...                                  autoGrantPermissions=true
    ...                                  noReset=true

***Test Cases***
See the first screen
    [Setup]          Start Session
    Start app
    Log in
    Check the first screen
    [Teardown]       Close Application

See the second screen
    [Setup]          Launch Application
    Check the first screen
    [Teardown]       Close Session

标签: appiumrobotframework

解决方案


尝试在功能中同时使用 fullReset=false 和 noReset=true。这可以解决您的问题。


推荐阅读