无法在Android模拟器

时间:2017-05-30 15:40:15

标签: selenium-webdriver automated-tests appium

无法启动应用,请找到相同的

以下跟踪

注意:相同的应用程序适用于葫芦,即我能够启动应用程序

  

org.openqa.selenium.WebDriverException:未知的服务器端错误   处理命令时发生。原始错误:发生错误   同时启动App。原始错误:用于启动应用的活动不会   存在或无法启动!确保它存在并且是可启动的   活动(警告:服务器未提供任何堆栈跟踪   信息)           命令持续时间或超时:11.16秒           构建信息:版本:' 2.53.0',修订版:' zasdqweqwe123',时间:' 2016-03-15 10:43:46'           系统信息:主机:' WNnsMM012sampel',ip:' 10.2.3.1sampel',os.name:' Windows 7',os.arch:' amd64',os.version:' 6.1',   java.version:' 1.8.0_131'           驱动程序信息:io.appium.java_client.android.AndroidDriver             at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)             at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)             at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown   资源)             at java.lang.reflect.Constructor.newInstance(Unknown Source)             在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)             在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)             在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)             at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:51)             at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)             在io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)             在org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)             在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:131)             在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:144)             在io.appium.java_client.DefaultGenericMobileDriver。(DefaultGenericMobileDriver.java:47)             在io.appium.java_client.AppiumDriver。(AppiumDriver.java:114)             在io.appium.java_client.AppiumDriver。(AppiumDriver.java:132)             在io.appium.java_client.android.AndroidDriver。(AndroidDriver.java:97)             at tests.BaseAppiumTest.setAppium(BaseAppiumTest.java:34)             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)             at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)             at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)             at java.lang.reflect.Method.invoke(Unknown Source)             在org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall(FrameworkMethod.java:50)             在org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)             在org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)             在org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)             在org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)             在org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)             在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)             在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)             在org.junit.runners.ParentRunner $ 3.run(ParentRunner.java:290)             在org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:71)             在org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)             在org.junit.runners.ParentRunner.access $ 000(ParentRunner.java:58)             在org.junit.runners.ParentRunner $ 2.evaluate(ParentRunner.java:268)             在org.junit.runners.ParentRunner.run(ParentRunner.java:363)             在org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)             在org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)             在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)             在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)             在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)             在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

    java.lang.NullPointerException
      at tests.BaseAppiumTest.teardown(BaseAppiumTest.java:40)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

我正在使用以下功能:

public class BaseAppiumTest 
{
    AndroidDriver driver;

    @Before
    public void setAppium() throws MalformedURLException {
        File classpathRoot = new File(System.getProperty("user.dir"));
        File appDir = new File(classpathRoot, "/apps/");
        File app = new File(appDir, "automation_test_artifact.apk");
        AppiumUtils appium = new AppiumUtils();
        appium.devicename = "Android Emulator";
        appium.app=app.getAbsolutePath();
        appium.appPackage="com.morrisons.instore.sit";
        appium.appActivity=".HomeActivity";
        appium.platformVersion="4.4";

        DesiredCapabilities capabilities = appium.getCapabilities();
        driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    }

    @After
    public void teardown()
    {
        driver.quit();
    }
}

1 个答案:

答案 0 :(得分:1)

尝试找出您尝试运行的应用的可启动活动名称。有时可能在androidmanifest.xml文件中未给出可启动活动名称。您可以使用以下命令验证是否存在可启动活动名称:

aapt dump badging <path-to-apk> | grep launchable-activity:\ name