Appium [已解决] 执行第二条 case 的时候报错 Original error: com.ndol.sale.starter/.patch.ui.FirstActivity never started.

Aquarius、 · 2016年08月03日 · 最后由 Aquarius、 回复于 2016年08月04日 · 2009 次阅读

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

共收到 4 条回复 时间 点赞
匿名 #2 · 2016年08月03日

同楼上,@After注解是每个用例方法执行完执行

#1 楼 @nancy2896 谢谢,改成@beforeclass@afterclass就可以了

Aquarius、 关闭了讨论 08月04日 09:39
Aquarius、 重新开启了讨论 08月04日 09:39
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册