简体   繁体   English

Appium Android-如何启动新活动?

[英]Appium Android - How to launch new activity?

Is there any possibility to switch from one Activity to another Activity with in the application? 在应用程序中是否有可能从一个活动切换到另一个活动?

Also, Can I know how the get previous test case result through coding? 另外,我可以知道如何通过编码获得先前的测试用例吗?

@Note: I am using TESTNG framework. @注意:我正在使用TESTNG框架。

Below is the code. 下面是代码。

// App2 capabilities
    String settingsAppPackageName="com.xxx.xxx.xxxx.dashBoard";
    String settingsAppActivityName="com.xxxx.xxxx.xxx.xxx.DashBoard";


    @Test(priority = 1)
    public void loginTC2(){

        System.out.println("Login 3333::>"+driver.currentActivity());

        if(driver.currentActivity().equals("com.xxx.xxx.xxxx.login.LoginActivity")){

            System.out.println("Login 6666::>"+driver.currentActivity());

            driver.findElement(By.id("com.xxxx.xxxx.xxxx:id/edtUserName")).sendKeys("xxxx");
            driver.findElement(By.id("com.xxxx.xxxx.xxxx:id/edtPassword")).sendKeys("xxxx");
            driver.findElement(By.id("com.xxxx.xxxx.xxxx:id/btnLogin")).click();


            // If action is executed then I want to navigate to DashboardActivity
            driver.startActivity(settingsAppPackageName, settingsAppActivityName);

        }else{
            System.out.println("Login 4444::>"+driver.currentActivity());


        }
    }

Thanks 谢谢

The first thing is to test if the activity you want is launching: 第一件事是测试您要启动的活动是否:

adb shell am start -n <app_package_name>/<full_activity_name>

If it goes smth like Starting: Intent {<>} without errors and you can see app launched on emulator/device, then you I ready to go with Appium. 如果它像Starting: Intent {<>}无误,并且您可以看到在模拟器/设备上启动了应用程序,那么您就可以使用Appium。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM