I tried to run the below piece code and getting the error Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: A new session could not be created.
public class TestCaller {
public static AppiumDriver driver;
public static void main(String[] args) throws MalformedURLException {
DesiredCapabilities capabilites = new DesiredCapabilities();
capabilites.setCapability("device", "Android");
capabilites.setCapability("deviceName", "GT-N7100");
capabilites.setCapability("platformVersion", "4.4.3");
capabilites.setCapability("platformName", "Android");
capabilites.setCapability("appPackage", "com.android.contacts");
capabilites.setCapability("appActivity", "com.android.contacts.activities.PeopleActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilites);
}
}
ERROR LOGS
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Could not find a connected Android device.) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 21.00 seconds
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33'
System info: host: 'Admin-PC', ip: '172.18.0.142', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0'
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:408)
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:599)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:176)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:107)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:40)
at TestContactsNativeApp.main(TestContactsNativeApp.java:27)
Solution
Sometimes it may happen that if we don't perform any action on our mobile device then it gets disconnected automatically and in the system tray the mobile is displayed as connected. So, the best solution of this is to disconnect your mobile first and then connect it again.
2 Comment(s)