I am trying to run my first test through Appium and getting the below error.
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Orig
Replace old chrome driver to new chrome driver in appium location, it worked for me.
The Appium location should be something like:
C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\
Appium version : 1.4.16.1
The safest way to set for android capabilities = DesiredCapabilities.android()
PS: You got session is not created because your script is not able to connect to selenium node/hub; you should check your configuration
As in your post stacktrace, it connects to http://**:9515/ (not like in your mentioned port 4723)
Though this issue is quite an old one and a lot of definition has changed on appium client usage along with the chrome driver version updates as well. Yet to what I could figure out was that the issue here was this from the logs :
ERROR: error: Chromedriver create session did not work. Status was 200 and body was {"sessionId":"ba9a494082776d6b4836da850072cbcb","status":13,"value":{"message":"unknown error: Device emulator-5554 is already in use\n (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86)"}}
which resulted further into :
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Did not get session redirect from Chromedriver) (WARNING: The server did not provide any stacktrace information)
and hence SessionNotCreatedException.
Simpler fix to this could be ensuring no other session is in progress before initiating another to avoid conflicts of ports and session failure.
Try running after commenting below statement
capabilities.setCapability("platformVersion", "4.4.2");
You need to set the below URL to http://0.0.0.0:9515/wd/hub
instead of ****:4723
...
WebDriver driver = new RemoteWebDriver(new URL(http://****:4723/wd/hub), capabilities);
Chromedriver's port defaults to 9515, not 4723. You should read the documentation on this. There are other capabilities that need to be set correctly (like BROWSER_NAME
)