我尝试使用Appium运行JUnit测试,如下所示。如果我设置capabilities.setCapability("appActivity", ".MainActivity");
,脚本运行正常。但是,当我尝试启动子活动时(如下面的脚本),它表示活动从未启动过。我一直在使用Robotium,它支持测试儿童活动而无需经过发射器活动;我希望我能在Appium上做同样的事情。
package com.test;
import io.appium.java_client.AppiumDriver;
import java.io.File;
import java.net.URL;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
public class ShowdownTest {
AppiumDriver driver;
@Before
public void setUp() throws Exception {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "Application");
File app = new File(appDir, "app-debug-unaligned.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName","Nexus 5");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.sample.app");
capabilities.setCapability("appActivity", ".ChildActivity1");
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@After
public void tearDown() throws Exception {
driver.quit();
}
@Test
public void test() {
//fail("Not yet implemented");
}
}
答案 0 :(得分:1)
使用命令aapt dump badging yourapk.apk
它显示所有可启动活动的原始活动名称。确保它与您所需的功能相匹配。这应该可以解决你的问题。