我必须从运行时本机应用程序切换到另一个本机应用程序。尝试使用下面提到的startActivty()
方法:
driver.startActivity(settingsAppPackageName, settingsAppActivityName);
&安培;
driver.startActivity(new Activity("package.activityname"));
使用 appium桌面与v1.4.1 ,非常感谢来自自动化极客的任何解决方案。
答案 0 :(得分:0)
最后,找到了解决方案。
static void launchSecurityXxxApp(AppiumDriver<AndroidElement> driver) throws MalformedURLException {
String appPackage="com.xxx.xxxx";
String appActivity="com.xxx.xxxx.Launchable";
Activity activity = new Activity(appPackage, appActivity);
activity.setStopApp(false);
((AndroidDriver<AndroidElement>) driver).startActivity(activity);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
答案 1 :(得分:0)
protected static final String appPackage1="app package name";
protected static final String appActivity1="your activity name";
protected static final String appPackage2="app package name";
protected static final String appActivity2="your activity name";
public static AndroidDriver<MobileElement> setupDriver(String appPackage, String appActivity) throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Any na,e");
caps.setCapability("udid", "your device uuid");
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "your device android version");
caps.setCapability("appPackage", appPackage);
caps.setCapability("appActivity", appActivity);
caps.setCapability("noReset", "true");
return new AndroidDriver<MobileElement>(new URL(
"http://127.0.0.1:4723/wd/hub"), caps);
}
public static void main(String[] args) throws MalformedURLException {
AppiumDriver<MobileElement> driver=setupDriver(appPackage1, appActivity1);
driver=setupDriver(appPackage2, appActivity2);
}