繁体   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