The first step to use Appium is to configure the system and the most common error that usually comes while configuring Appium is: Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: 'java -version' failed. Error: spawn ENOENT)
The following reasons may be possible of this uneven behavior:
- ANDROID_HOME variable might not be set.
- JAVA_HOME variable might not be set.
- Make sure that ADB exists under Android_SDK\platform-tools.
- Also make sure that Android exist under Android_SDK\tools.
To confirm that everything is set correctly, just run appium-doctor -android from the command prompt. Please make sure that you are running this command from .bin folder; eg: "C:\Program Files (x86)\Appium\node_modules\.bin". If everything is already set correctly then the following output should be displayed on command prompt:
C:\Program Files (x86)\Appium\node_modules\.bin>appium-doctor -android
Running Android Checks
? ANDROID_HOME is set to "E:\Android test\adt-bundle-windows-x86_64-20140702\adt
-bundle-windows-x86_64-20140702\sdk"
? JAVA_HOME is set to "C:\Program Files\Java\jdk1.8.0."
? ADB exists at E:\Android test\adt-bundle-windows-x86_64-20140702\adt-bundle-wi
ndows-x86_64-20140702\sdk\platform-tools\adb.exe
? Android exists at E:\Android test\adt-bundle-windows-x86_64-20140702\adt-bundl
e-windows-x86_64-20140702\sdk\tools\android.bat
? Emulator exists at E:\Android test\adt-bundle-windows-x86_64-20140702\adt-bund
le-windows-x86_64-20140702\sdk\tools\emulator.exe
? Android Checks were successful.
? All Checks were successful
After setting all the above components if still you are facing the same issue then set system32 location as the PATH variable in environment variables. Add %SystemRoot%\system32 at the end of PATH variable in System variables.

Save all the changes and restart the system. Now try to run the Appium code and you will not face the above issue.
0 Comment(s)