Getting “org.openqa.selenium.SessionNotCreatedException: A new session could not be created” error.
following is the appium log:
info: → POST /wd/hub/session {“desiredCapabilities”:{“browserName”:“Chrome”,“platformName”:“Android”,“deviceName”:“09478d300f4133f6”}}
info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)
info: Set mode: Proxying straight through to Chromedriver
info: [debug] Looks like we want chrome on android
info: [debug] Creating new appium session c9eefe65-966d-4e6f-bb26-d39bcbf014df
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it’s already on the device
info: [debug] Checking whether adb is present
info: [debug] Using adb from D:\UD\sdk\platform-tools\adb.exe
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices…
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device 09478d300f4133f6
info: [debug] Setting device id to 09478d300f4133f6
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 wait-for-device
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 shell “echo ‘ready’”
info: [debug] Starting logcat capture
info: [debug] Pushing unlock helper app to device…
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 install “D:\softies\Programs\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk”
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 shell “dumpsys window”
info: Unlocking screen
info: [debug] Screen is locked, trying to unlock
info: [debug] Getting device API level
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 22
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock”
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 shell “dumpsys window”
info: [debug] Screen is locked, trying to unlock
info: [debug] Getting device API level
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 22
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock”
info: [debug] [BOOTSTRAP] [debug] Emitting system alert message
info: [debug] Emitting alert message…
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 shell “dumpsys window”
info: [debug] Screen is unlocked, continuing
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 push “D:\softies\Programs\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar” /data/local/tmp/
info: Starting App
info: [debug] Attempting to kill all ‘uiautomator’ processes
info: [debug] Getting all processes with ‘uiautomator’
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 shell “ps ‘uiautomator’”
info: [debug] Attempting to kill process 10627
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 shell “kill 10627”
info: [debug] Running bootstrap
info: [debug] spawning: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap
info: [debug] UiAutomator exited
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 shell “echo ‘ping’”
info: [debug] Attempting to uninstall app
error: UiAutomator quit before it successfully launched
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Cleaning up android objects
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json…
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] Pushing command to appium work queue: [“getDataDir”,{}]
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“getDataDir”,“params”:{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] dataDir set to: /data/local/tmp
info: [debug] Creating Chrome session
info: [debug] Set chromedriver binary as: D:\softies\Programs\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: [debug] Ensuring Chromedriver exists
info: [debug] Killing any old chromedrivers, running: FOR /F “usebackq tokens=5” %a in (netstat -nao ^| findstr /R /C:"9515 "
) do (FOR /F “usebackq” %b in (TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe
) do (IF NOT %b==“” TASKKILL /F /PID %b))
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:“/data/local/tmp”}
info: [debug] No old chromedrivers seemed to exist
info: [debug] Spawning chromedriver with: D:\softies\Programs\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: [debug] [CHROMEDRIVER] Starting ChromeDriver 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf) on port 9515
Only local connections are allowed.
info: [debug] Making http request with opts: {“url”:“http://127.0.0.1:9515/wd/hub/session",“method”:“POST”,“json”:{“sessionId”:null,“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.android.chrome”,“androidDeviceSerial”:"09478d300f4133f6”}}}}
info: [debug] [CHROMEDRIVER STDERR] [0.013][SEVERE]: bind() returned an error: Only one usage of each socket address (protocol/network address/port) is normally permitted. (0x2740)
info: [debug] [CHROMEDRIVER] Port not available. Exiting…
info: [debug] [CHROMEDRIVER STDERR] [0.013][WARNING]: Unknown error 10038 mapped to net::ERR_FAILED
info: [debug] Chromedriver exited with code 1
info: [debug] Getting connected devices…
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 devices
info: [debug] 1 device(s) connected
info: [debug] executing cmd: D:\UD\sdk\platform-tools\adb.exe -s 09478d300f4133f6 shell “am force-stop com.android.chrome”
info: [debug] [BOOTSTRAP] [debug] Emitting system alert message
info: [debug] Emitting alert message…
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] Cleaning up appium session
error: Chromedriver create session did not work. Status was 200 and body was {“sessionId”:“0ac22d6cf7fa7ac20ea791f94e722e79”,“status”:21,“value”:{“message”:“timeout: Adb command timed out after 30 seconds\n (Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Windows NT 6.1 SP1 x86)”}}
info: [debug] Cleaning up appium session
info: [debug] Error: Did not get session redirect from Chromedriver
at null. (D:\softies\Programs\Appium\node_modules\appium\lib\devices\android\chromedriver.js:222:12)
at Request._callback (D:\softies\Programs\Appium\node_modules\appium\lib\devices\common.js:121:5)
at Request.self.callback (D:\softies\Programs\Appium\node_modules\appium\node_modules\request\request.js:121:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request. (D:\softies\Programs\Appium\node_modules\appium\node_modules\request\request.js:985:14)
at Request.EventEmitter.emit (events.js:117:20)
at IncomingMessage. (D:\softies\Programs\Appium\node_modules\appium\node_modules\request\request.js:936:12)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickDomainCallback (node.js:459:13)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Did not get session redirect from Chromedriver)”,“origValue”:“Did not get session redirect from Chromedriver”},“sessionId”:null}
info: ← POST /wd/hub/session 500 37351.375 ms - 214
error: Failed to start an Appium session, err was: Error: Did not get session redirect from Chromedriver
Following is the code using to launch Facebook:
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import java.io.File;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.*;
public class LaunchMobileBrowser
{
private AndroidDriver driver;
@BeforeTest
public void setup() throws Exception
{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“deviceName”,“09478d300f4133f6”);
capabilities.setCapability(“platformName”, “ANDROID”);
capabilities.setCapability(“browserName”, “Chrome”);
driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
}
@Test
public void launchBrowser() throws InterruptedException
{
driver.get("http://www.facebook.com");
Thread.sleep(5000);
driver.findElementByName("email").sendKeys("[email protected]");
driver.findElementByName("pass").sendKeys("ABC");
driver.findElementByName("login").click();
}
}
Following is environment details:
Appium: 1.3.4.1
Chrome driver: 2.14(tried) also with 2.15
Windows 7
LG Nexus OS: 5 and 5.1