簡體   English   中英

無法使用appium-android創建新會話,但是我給了正確的包名稱

[英]Not able to create a new session using appium-android, however I am giving the right package name

我正在嘗試在Android平台上使用appium自動化應用程序。 ---考慮該應用程序就像watsapp。 下載該應用程序后,用戶必須對其進行配置,他才能使用它。 1)我能夠啟動該應用程序,但未顯示繼續使用android inspector的選項。 2)我想從提供密碼的地方啟動我的應用程序,它會進入watsapp的聊天頁面。

public class TestAndroidchatAPP {

    static AppiumDriver<MobileElement> driver;

    public static void main(String[] args) {
        try {

            chatAPP();
        } catch (Exception exp) {
            System.out.println(exp.getMessage());
        }

    }

    public static void chatAPP() throws IOException {
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("deviceName", "samsungGalaxyS5");
        caps.setCapability("uuid", "446bc30b");
        caps.setCapability("platformName", "Android");
        caps.setCapability("platformVersion", "6.0.1");
        caps.setCapability("appPackage", "com.chatAPP.chatapp");
        //caps.setCapability("appActivity", "com.chatAPP.chatapp.LauncherActivity"); //its working.
        caps.setCapability("appActivity", "com.chatAPP.chatapp.view.LoginPicodeActivity");

        URL url = new URL("http://127.0.0.1:4723/wd/hub");
        driver = new AppiumDriver<MobileElement>(url, caps);
        System.out.println("Application started");
    }
}

在logcat中顯示以下錯誤

Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.chatAPP.chatapp' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Cannot start the 'com.chatAPP.chatapp' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Activity name '.com.chatAPP.chatapp.view.LoginPicodeActivity' used to start the app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'

    Driver info: driver.version: AppiumDriver
    remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.chatAPP.chatapp' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Cannot start the 'com.chatAPP.chatapp' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Activity name '.com.chatAPP.chatapp.view.LoginPicodeActivity' used to start the app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity
        at getResponseForW3CError (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:826:9)
        at asyncHandler (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:447:37)
        at process._tickCallback (internal/process/next_tick.js:68:7)
    Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'

基於此日志: Activity name '.com.chatAPP.chatapp.view.LoginPicodeActivity' used to start the app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity Activity name '.com.chatAPP.chatapp.view.LoginPicodeActivity' used to start the app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity

LoginPicodeActivity不是可啟動的活動,您必須在應用程序代碼庫的AndroidManifest.xml內添加屬性LAUNCHER。

<category android:name="android.intent.category.LAUNCHER" />

您可以在此處查看有關清單的說明。

  1. 確保提供正確的Activity類名稱,您可以像這樣確定它:

    • 啟動您要在設備上測試的應用程序
    • 執行以下adb命令

       adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp' 

    如果未安裝該應用程序,請改用app所需的功能,並提供.apk文件的完整路徑或URL。

  2. 鑒於您要自動化Android 6.0.1設備,請考慮設置automationName所需的功能

     caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2"); 

    否則,您將無法找到元素並且測試可能不可靠 ,您應該使用uiautomator2 for Android> = 5.0

我做了,當我添加下面的兩行代碼時,它的工作正常。

caps.setCapability("noReset", true);
caps.setCapability("fullReset", false);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM