Failed to create a new session. error in code for appium
Unable to create a new session. (Original error: Requested a new session but it continued) This error is displayed if I run my code a second time. Works fine the first time
Writing code for selenium
public static void main(String[] args) throws MalformedURLException{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appium-version", "1.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("deviceName", "AndroidTest");
System.out.println("iii");
capabilities.setCapability("app", "/Users/gurpreet/Desktop/nimbuzz-3.2.0-rc4-debug.apk");
System.out.println("iii");
WebDriver driver = new RemoteWebDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
driver.findElement(By.id("com.nimbuzz:id/btnSignInSplash")).click();
}
}
Can anyone suggest a solution for this /
try the following
In appium tool -> general settings-> select override existing sessions
a) add the code that leaves your driver.
driver.Quit ();
b) via session via Appium.
c) If you still get the error, you need to kill the ChromeDriver process from the task manager. and try running the script again.
Add this to your code:
public void teardown(){
driver.quit(); }
The problem is that the test run did not close and you tried to run it again, adding the above code makes sure the previous run finished.
Hope it helps.
Use the following code
public static void main(String[] args) throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Android Emulator");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");
capabilities.setCapability(MobileCapabilityType.APP, "C:/Users/gurpreet/Desktop/nimbuzz-3.2.0-rc4-debug.apk");
WebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
This code assumes your application server is running on localhost and port 4723