0
votes

log:org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{appActivity=com.knowarth.hrmsapp.ui.LoginActivity, platformVersion=7.0, androidPackage=com.knowarth.hrmsapp, platformName=Android, device=Android, deviceName=Nexus 5X API 24}], required capabilities = Capabilities [{}] Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800' System info: host: 'KA-LPT-104', ip: '192.168.43.85', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_60' Driver info: driver.version: AndroidDriver at io.appium.java_client.remote.AppiumProtocolHandShake.lambda$1(AppiumProtocolHandShake.java:95) at java.util.Optional.orElseThrow(Unknown Source) at io.appium.java_client.remote.AppiumProtocolHandShake.createSession(AppiumProtocolHandShake.java:95) at io.appium.java_client.remote.AppiumCommandExecutor.doExecute(AppiumCommandExecutor.java:111) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:162) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42) 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:244) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144) at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:88) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:112) at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:73) at com.ka.tests.Appium_Webinar.setUp(Appium_Webinar.java:42) 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108) at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:326) at org.testng.SuiteRunner.run(SuiteRunner.java:289) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301) at org.testng.TestNG.runSuitesLocally(TestNG.java:1226) at org.testng.TestNG.runSuites(TestNG.java:1144) at org.testng.TestNG.run(TestNG.java:1115) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)

2
Have you created the emulator - Nexus 5X API 24?Thejus Krishna
Yes, I have created it.Bhumil Raval QA
Is it possible to see the entire appium logs?Thejus Krishna
I am not able to add appium log in comment, because its too long.Bhumil Raval QA
[BaseDriver] The following capabilities were provided, but are not recognized by appium: androidPackage, device. [AndroidDriver] Error: The desired capabilities must include either an app, appPackage or browserName at Object.wrappedLogger.errorAndThrow .Bhumil Raval QA

2 Answers

0
votes

The issue here is, you are creating the session but not closing it. Hence when you are running the test for second time, it says "unable to allocate session".

Use these methods to start and stop the appium and it solves your problem.

static AppiumDriverLocalService appiumService;
public static void start() throws IOException {
    AppiumServiceBuilder builder = new AppiumServiceBuilder().withArgument(GeneralServerFlag.SESSION_OVERRIDE)
                                   .withArgument(GeneralServerFlag.STRICT_CAPS);
    appiumService = builder.build();
    appiumService.start();
    System.out.println("appium server is started");
}

public static void stop() throws IOException{
    appiumService.stop();
    System.out.println("appium server is stopped");
}
0
votes

I got this issue resolve by downgrading java client version from 5.0.0 to 4.1.2. Thanks.

Hope this will help you. Happy testing!!