无法创建新会话原始错误:com.xxx.xxx / view.activity.ActivityStart从未启动过

时间:2017-02-15 10:40:33

标签: 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();
 }

对此表示感谢。 谢谢!!

2 个答案:

答案 0 :(得分:0)

org.openqa.selenium.SessionNotCreatedException:

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

由于以下原因而发生。

  1. 当您没有正确设置功能时(包括appPackage,appPath等)。
  2. 当设备不包含您在 appPackage 中提及的应用程序(.apk)。
  3. 如果您提及错误的 appPath
  4. 在您的情况下,您的appPath是错误的,即&#34; \ apks \ mediashare-debug.apk&#34;

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

    希望这些可以帮助你。

答案 1 :(得分:0)

它清楚地说appium无法使用设备创建会话。以下是为了与设备创建会话并开始执行而需要传递的强制功能。

mobileCapabilities.setCapability("appPackage", "com.flipkart.android");
mobileCapabilities.setCapability("appActivity", 
"com.flipkart.android.SplashActivity");
mobileCapabilities.setCapability("platformName", "Android");
mobileCapabilities.setCapability("platformVersion", "6.0.1");
mobileCapabilities.setCapability("deviceName", "Ash");
mobileCapabilities.setCapability("udid", "45s56f82r6");
mobileCapabilities.setCapability("app","YourAppPath/Flipkart_com.flipkart.android.apk");
mobileCapabilities.setCapability("noReset", "true");

如果是iOS,您不需要传递appPackage和appActivity。