java - 无法创建新 session 原始错误:com. xxx.xxx/view.activity.ActivityStart从未启动

标签 java android appium

当我运行正确启动的基本 appium 代码应用程序时,但出现以下错误。 应用程序已正确加载,但测试失败。

org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: XXX.XXX.XXX.view.activity.ActivityStart never started.

 Current: com.XXX.XXXcom.pearsoned.auth.ui.AuthenticationActivity) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 32.99 seconds
Build info: version: '2.46.0', revision: '61506a4624b13675f24581e453592342b7485d71', time: '2015-06-04 10:22:50'
System info: host: 'LKSRIWL-9Y3BF72', ip: '192.168.56.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_101'
Driver info: io.appium.java_client.android.AndroidDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:27)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
    at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:22)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:202)
    at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:50)
    at com.pearson.eselenium.liverPool.testmob.WhatsApp.testapp(WhatsApp.java:50)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    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)

java.lang.NullPointerException
    at com.XXX.XXX.liverPool.testmob.WhatsApp.quit(WhatsApp.java:62)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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)

这是我的 Apium 代码:​​

public class WhatsApp
{
 WebDriver dr;

 @SuppressWarnings("rawtypes")
 @Test
 public void testapp() throws MalformedURLException, InterruptedException {
  File app = new File(System.getProperty("user.dir") + "\\apks\\mediashare-debug.apk");

  DesiredCapabilities capabilities = DesiredCapabilities.android();

  capabilities.setCapability("deviceName", "motorola-nexus_6-ZX1G323XDM");
  capabilities.setCapability("platformVersion", "6.0.1");
  capabilities.setCapability("platformName", "Android");

  capabilities.setCapability("app", app.getAbsolutePath());


  dr = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
  dr.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);


  // clicking
  Thread.sleep(10000);

 }

 @AfterMethod
 public void quit() {
  dr.quit();
 }

感谢对此的帮助。 谢谢你!!

最佳答案

org.openqa.selenium.SessionNotCreatedException:

当 appium 无法在您的设备与其自身之间建立任何 session 时,就会出现这些异常。

出现这种情况的原因如下。

  1. 当您没有正确设置功能时(包括appPackage、appPath等)。
  2. 当设备不包含您在appPackage中提到的应用程序(.apk)时。
  3. 当您提及错误的appPath时。

在您的情况下,您的 appPath 是错误的,即 "\apks\mediashare-debug.apk"

请提及写入路径或在您的设备上安装应用程序。

希望这些对您有帮助。

关于java - 无法创建新 session 原始错误:com. xxx.xxx/view.activity.ActivityStart从未启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42247029/

相关文章:

Android 如何从样式或主题更改选项卡颜色

java - 锁定 GLSurfaceView 线程

java - 在使用 Selenium 的 Appium 自动化测试中命名屏幕截图文件的 SimpleDateFormat 方法的其他模式是什么?

java - Appium错误:Exception in thread "main" org. openqa.selenium.SessionNotCreatedException:无法创建新的远程 session

java - 是否可以在一次调用中调用 Thread start() 和 join() ?

java - 未找到 JsonObject

java - 嵌入式 Nashorn - 沙箱执行

android - 找不到此 SQLite 语句中的语法错误

testing - 此 session 不支持 appium css 选择器

java - 共享 jar 和 noclassdeffound java