1.执行第二条 case 的时候报错
报错信息:
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: com.ndol.sale.starter/.patch.ui.FirstActivity never started. Current: com.ndol.sale.starter/.patch.ui.place.ChooseSchoolActivity) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 28.36 seconds
public class Demo {
private AndroidDriver driver;
@Before
public void calc() throws Exception {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "apps");
File app = new File(appDir, "test.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");// 这句不是必须的
capabilities.setCapability("deviceName", "3dec908a");
capabilities.setCapability("platformVersion", "4.2.2");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.ndol.sale.starter");
capabilities.setCapability("appActivity", ".patch.ui.FirstActivity");
capabilities.setCapability("waitActivity",".patch.ui.FirstActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
}
@After
public void tearDown() throws Exception {
//driver.removeApp("com.ndol.sale.starter");
driver.quit();
}
@Test
public void N001Skip() throws Exception {
System.out.println("第一条测试:跳过引导页面");
Thread.sleep(6000);
driver.findElementById("com.ndol.sale.starter:id/skip").click();
java.lang.String activity = ".patch.ui.place.ChooseSchoolActivity";
java.lang.String activity1 = driver.currentActivity();
if (activity1.equals(activity)){
System.out.println("Pass:第一条跳过引导页面测试通过");
}
else {
throw new Exception("Fail:第一条跳过引导页面失败");
}
}
@Test
public void N002SelectAddress() throws Exception{
System.out.println("第二条测试:选择地址");
driver.findElementById("com.ndol.sale.starter:id/placeedit").click();
driver.findElementById("com.ndol.sale.starter:id/placeedit").sendKeys("测试学校3");
Thread.sleep(2000);
driver.findElement(By.id("com.ndol.sale.starter:id/placeedit")).click();
}
尝试过 appium --no-reset,还有 waitforActivity 都不可以
https://testerhome.com/topics/1770
https://testerhome.com/topics/2287