A new session could not be created. Details: Problem getting session data for driver type AndroidDriver

I am trying to test Android device on MAC OS X, using Appium (in Java). The build path includes these:

java-client-<version>.jar
java-client-<verson>-sources.jar
selenium-java-<version>.jar
selenium-server-standalone-<version>.jar

(the version of the last 2 is the same), and TestNG.

Starting the Appium server (i am using the GUI) works fine and the application (which is already installed on the device) launches. Starting to debug my eclipse project which contains the following lines, i am getting the error for the 3rd line.

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Plus");
AppiumDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

The full error i am getting is:

org.openqa.selenium.SessionNotCreatedException: A new session could not be created. Details: Problem getting session data for driver type AndroidDriver; does it implement 'get driverData'?

I am also getting the same error.

In the following links, they told as it was fixed in Appium v1.5.3.

But I am also using the Appium v1.5.3. Still I am getting the following error occasionally

A new session could not be created. Details: Problem getting session data for driver type AndroidDriver; does it implement ā€˜get driverDataā€™?

My configuration are:-

Appium - 1.5.3
Android - 5.0.1
Java-client - 4.0.0

Do anybody knows how to solve this issue ?

Sometimes I got the same error but normally I end finding an own mistake.

Make sure your previous session has closed correctly, or all the capabilities you provided are correct (in client), make sure you donā€™t have another server instance running in backgroundā€¦ Things like that can broke the handshake between client and server.

Hope it helps you

@slipy12 Thanks for the information. It works now. I havenā€™t close the session.

1 Like

hello friends ,

i am getting error even if i have handled exception , its not performing try catch operation and throws no such element exception , please anyone can help in this : my code---------------
caps.setCapability(ā€œautoGrantPermissionsā€, ā€œtrueā€);
AndroidDriver driver = new AndroidDriver(new URL(ā€œhttp://0.0.0.0:4723/wd/hubā€),caps);
// driver.findElement(MobileBy.id(ā€œpermission_allow_buttonā€)).click();
driver.pressKeyCode(AndroidKeyCode.KEYCODE_HOME);
Thread.sleep(5000);
driver.findElement(By.xpath("//android.widget.TextView[@text=ā€˜Appsā€™]")).click();
Thread.sleep(5000);
MobileElement e = (MobileElement) driver.findElement(By.xpath("//android.widget.TextView[@text=ā€˜Settingsā€™]"));
try{
** while(e.isDisplayed())**
** {e.click();**
** break;**


** }**
** }catch(Exception f){**
** driver.pressKeyCode(AndroidKeyCode.KEYCODE_PAGE_DOWN);**
** Thread.sleep(5000);**
** }**


** driver.findElement(By.xpath("//android.widget.TextView[@text=ā€˜Wi-Fiā€™]")).click();**


}

i got stuck in this ā€¦

Hello @gandharavkatyal,

The Exception is thrown at the line where you wrote <ā€˜driver.findElement(By.xpath(ā€œyour_xpathā€))ā€™> which is not enclosed within try block. Enclose this line within try{} block and also add implicit timeout for driver instance so that it will keep finding element multiple time.

I am keep getting this error, I think session override function is not working in 1.6.5.

Which version is recommended for this ??