Appium - Timing out and Never got a response from command - appium

We have UI tests to be started by Jenkins using Appium, but it results with an error:
remote stacktrace: UnknownError: An unknown server-side error occurred
while processing the command. Original error: Error getting AVD with
retry. Original error: Condition unmet after 60063 ms. Timing out.
And there is no emulator process found when Appium's task is running.
Also Appium's output says:
[debug] [ADB] Emulator Nexus_5X_API_26 not running
[debug] [ADB] Trying to find Nexus_5X_API_26 emulator
[debug] [ADB] Getting connected emulators
[debug] [ADB] Getting connected devices...
[debug] [ADB] 0 device(s) connected
[debug] [ADB] 0 emulator(s) connected
OK, I see that device wasn't started and this is cause for the "Timeout" error.
But why Appium can't start it?
I'm able to get the emulator executable, and Jenkin's job which is starting Appium's task can see the device:
[Pipeline] sh
+ avdmanager list avd
...
Name: Nexus_5X_API_26
Device: Nexus 5X (Google)
Path: /home/user/.android/avd/Nexus_5X_API_26.avd
Target: Google Play (Google Inc.)
Based on: Android 8.0 (Oreo) Tag/ABI: google_apis_playstore/x86
Skin: 1080x1920
Sdcard: 100 MB
---------
Name: test
Path: /home/user/.android/avd/test.avd
Target: Google APIs (Google Inc.)
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
[Pipeline] sh
+ emulator -list-avds
Nexus_5X_API_26
test
If I'm starting device manually just by running:
/android/Android/sdk/emulator/emulator -avd Nexus_5X_API_26
And trigger Jenkin's job after this - I have another error:
...
[ADB] Using adb from /android/Android/sdk/platform-tools/adb
[debug] [ADB] Trying to find Nexus_5X_API_26 emulator
[debug] [ADB] Getting connected emulators
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] 1 emulator(s) connected
[debug] [ADB] Sending telnet command to device: avd name
[debug] [ADB] Getting running emulator port
[debug] [ADB] Socket connection to device created
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1542807589908 (15:39:49 GMT+0200 (EET))
[debug] [W3C] Encountered internal error running command: Error: Error getting AVD. Original error: Never got a response from command
[debug] [W3C] at ADB.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/tools/system-calls.js:488:11)
...
Any ideas?
Can't even google anything with the "appium Never got a response from command" request...
Also, I'm not able to reproduce this issue on my workstation's laptop - all works just perfectly.
UPD Properties are:
<profile>
<id>linux-emulator-8.0</id>
<properties>
<hub.url>http://0.0.0.0:4723/wd/hub</hub.url>
<device.name>Android Emulator</device.name>
<avd>Nexus_5X_API_26</avd>
<platform.name>Android</platform.name>
<platform.version>8.0</platform.version>
<auto.grant.permissions>true</auto.grant.permissions>
<full.reset>true</full.reset>
<no.reset>false</no.reset>
<app.path>/home/user/project/project.apk</app.path>
<app.name>com.gen.workoutme</app.name>
<screenshot.path>
${project.basedir}/../screenShots/${platform.name}/${platform.version}/${device.name}/
</screenshot.path>
<automation.name>UiAutomator2</automation.name>
</properties>
</profile>
UPD 2 Not sure how - but not it works if run emulator manually.
But still, there is a problem with starting the emulator from Appium itself.
Found the weird error in its log:
[ADB] [AVD OUTPUT] Fatal: QXcbConnection: Could not connect to display ((null):0, (null))
[ADB] [AVD OUTPUT] INFO: QtLogger.cpp:66: Fatal: QXcbConnection: Could not connect to display ((null):0, (null))
[ADB] Emulator avd Nexus_5X_API_26 exited with code null, signal SIGABRT
Can't google for reason yet but it looks like the main issue - something with a connection to the $DISPLAY, although it present.

I am able to start and run tests on emulator without any problem. I use following three capabilities along with other capabilities while setting up the driver.
avd: Name of AVD
avdLaunchTimeout: Time out to wait for emulator to launch.
avdReadyTimeout: Time out to wait for emulator to get ready.
Try using these capabilities and you should be good.
Also check if there is any updates for Android SDK and emulator. If there is update available, it's good idea to update it.

Settings or python:
options = UiAutomator2Options()
options.avd = 'YOUR_AVD_NAME'
# Timeout to wait until Android Emulator is started in milliseconds
options.avd_launch_timeout = 25 * 1000
# Timeout to wait until Android Emulator is fully booted and is ready for usage in milliseconds
options.avd_ready_timeout = 20 * 1000
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', options=options)

Related

Can I do Appium inspector connected simulator without error code 65

I had started a session between appium server and simulator(at xcode).
But xcodebuild failed with code 65
xcodebuild error message:
[debug] [W3C]
[debug] [W3C] at quitAndUninstall (/usr/local/Cellar/appium/1.22.3/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:588:15)
[debug] [W3C] at /usr/local/Cellar/appium/1.22.3/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:623:11
[debug] [W3C] at wrapped (/usr/local/Cellar/appium/1.22.3/libexec/lib/node_modules/appium/node_modules/asyncbox/lib/asyncbox.js:60:13)
[debug] [W3C] at retry (/usr/local/Cellar/appium/1.22.3/libexec/lib/node_modules/appium/node_modules/asyncbox/lib/asyncbox.js:43:13)
[debug] [W3C] at retryInterval (/usr/local/Cellar/appium/1.22.3/libexec/lib/node_modules/appium/node_modules/asyncbox/lib/asyncbox.js:70:10)
[debug] [W3C] at /usr/local/Cellar/appium/1.22.3/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:603:7
[debug] [iOSSim] The simulator has '0' bundles which have 'WebDriverAgentRunner-Runner' as their 'CFBundleName':
[debug] [WebDriverAgent] No WDAs on the device.
I have kwnown that appium inspector connected with simulator does not need webAgentDriver. It isn't true?
In concolusion,
A simulator must need a WebDriverAgent? not for only a real device?
What is webDriverAgent? I think that it only let appium control iOS devices.
If using xcode 14 we need to have appium 2 and appium inspector installed to be able to access the app
Make sure you have node 16.16, if you don’t you can install nvm and use it to install multiple versions of node on the machine, you can fine NVM here
Install Appium 2 using: npm install -g appium#next
Once Appium is installed run appium -v to confirm that you have version > 2
Install XCUITest driver: appium driver install xcuitest
Install UIAutomator2: appium driver install uiautomator
Run appium driver list to confirm that both drivers are installed
Install Appium Inspector: can be downloaded here, download the latest version.

The application at <path> does not exist or is not accessible using Appium

I'm learning appium using eclipse and got stuck on launching my emulator. I tried different things such as moving the file around in the folder structure but I keep getting file does not exist or is not accessible I tried searching for the answer but nothing is helping.
package myAppiumTutorial;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileCapabilityType;
public class Base {
public static void main(String[] args) throws MalformedURLException {
// TODO Auto-generated method stub
File f = new File("scr");
File fs = new File(f,"ApiDemos-debug.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "MyFirstEmu");
cap.setCapability(MobileCapabilityType.APP, fs.getAbsolutePath());
AndroidDriver<AndroidElement> driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"),cap);
Logs from appium
[Appium] Setting automation to 'UiAutomator1'.
[Appium] Appium v1.13.0 creating new AndroidDriver (v4.15.1) session
[Appium] Capabilities:
[Appium] platformName: android
[Appium] app: C:\Users\Zamranj\eclipse-workspaceNew\AppiumIntro\scr\ApiDemos-debug.apk
[Appium] deviceName: MyFirstEmu
[debug] [BaseDriver] W3C capabilities {"alwaysMatch":{"platformNa... and MJSONWP desired capabilities {"app":"C:\\Users\\Zamranj\... were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {"alwaysMatch":{"platformNa...
[BaseDriver] Session created with session id: 638fc0a9-1aa0-4b56-ba69-3c854b8e1816
[ADB] Found 1 'build-tools' folders under 'C:\Users\Zamranj\AppData\Local\Android\Sdk' (newest first):
[ADB] C:/Users/Zamranj/AppData/Local/Android/Sdk/build-tools/28.0.3
[ADB] Using 'adb.exe' from 'C:\Users\Zamranj\AppData\Local\Android\Sdk\platform-tools\adb.exe'
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[AndroidDriver] Using device: emulator-5554
[ADB] Using 'adb.exe' from 'C:\Users\Zamranj\AppData\Local\Android\Sdk\platform-tools\adb.exe'
[debug] [ADB] Setting device id to emulator-5554
[debug] [ADB] Running 'C:\Users\Zamranj\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk'
[debug] [ADB] Current device property 'ro.build.version.sdk': 25
[debug] [ADB] Device API level: 25
[AndroidDriver] Consider setting 'automationName' capability to 'uiautomator2' on Android >= 6, since UIAutomator framework is not maintained anymore by the OS vendor.
[debug] [AndroidDriver] Shutting down Android driver
[debug] [AndroidDriver] Called deleteSession but bootstrap wasn't active
[debug] [ADB] Running 'C:\Users\Zamranj\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell am force-stop io.appium.unlock'
[debug] [AndroidDriver] Not cleaning generated files. Add `clearSystemFiles` capability if wanted.
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1559218980295 (07:23:00 GMT-0500 (Central Daylight Time))
[debug] [W3C] Encountered internal error running command: Error: The application at 'C:\Users\Zamranj\eclipse-workspaceNew\AppiumIntro\scr\ApiDemos-debug.apk' does not exist or is not accessible
[debug] [W3C] at APPLICATIONS_CACHE_GUARD.acquire (C:\Users\Zamranj\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\helpers.js:159:13)
[HTTP] <-- POST /wd/hub/session 500 2956 ms - 835
[HTTP]
Location of my apk
enter image description here
Your app is not in the src folder.
Instead it is in src/myAppiumTutorial folder.
So in line 17 change the folder to "src/myAppiumTutorial".
And see if it work.
I believe your problem lies with the way you're trying to load your file in.
Try the following:
File f = new File(classLoader.getResource("ApiDemos-debug.apk").getFile());
Please also take a look at the following:
Class.getResource(String)
Class.getResourceAsStream(String)
On Windows 10, I had to use the following double backslash syntax for the .apk file to be found.
caps.setCapability(MobileCapabilityType.APP, "C:\\Users\\Dad\\gitRepos\\myProjects\\AppiumJavaTestNGProject\\src\\test\\resources\\apps\\my.apk");
Only after I did that was the .apk findable by Appium server at runtime. Normally I work on Mac and the pathing is completely different.

Appium desktop server error when starting session could not sign with default certificate

I cannot start a new session on my Appium desktop server. I haven't found any fix that works for me. This is my error message:
Encountered internal error running command: Error: Could not sign with
default certificate. Original error Command ''C:\\Program
Files\\Java\\jdk1.8.0_181\\bin\\java.exe' -jar 'C:\\Program Files
(x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-
adb\\jars\\sign.jar' 'C:\\Program Files
(x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-
uiautomator2-server\\apks\\appium-uiautomator2-server-v1.12.0.apk' --
override' exited with code 1
Logs:
[Appium] Creating new AndroidUiautomator2Driver (v1.12.0) session
[Appium] Capabilities:
[Appium] app: "myapp/path/"
[Appium] appActivity: mydeviceActivity
[Appium] appPackage: base.apk
[Appium] automationName: UiAutomator2
[Appium] deviceName: OPPO F1s
[Appium] platformName: Android
[Appium] platformVersion: 5.1
[Appium] newCommandTimeout: 0
[Appium] connectHardwareKeyboard: true
[BaseDriver] Creating session with MJSONWP desired capabilities: {"app":"https://drive.googl...
[BaseDriver] The following capabilities were provided, but are not recognized by appium: connectHardwareKeyboard.
[BaseDriver] Session created with session id: a231071d-b167-42f3-9c4c-ffecc32e9076
............
[BaseDriver] Skipping 'https://drive.google..........' caching, because the HEAD response didn't return any valid Last-Modified headers
[UiAutomator2] Checking whether app is actually present
[AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_181
[ADB] Checking whether adb is present
[ADB] Found 1 'build-tools' folders under 'C:\Program Files\Android\SDK' (newest first):
[ADB] C:/Program Files/Android/SDK/build-tools/28.0.2
[ADB] Using adb.exe from C:\Program Files\Android\SDK\platform-tools\adb.exe
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[AndroidDriver] Looking for a device with Android '5.1'
[ADB] Setting device id to SOVW6PUS99999999
[ADB] Getting device platform........................................
[ADB] Running 'C:\Program Files\Android\SDK\platform-tools\adb.exe -P 5037 -s SOVW6PUS99999999 shell am force-stop io.appium.uiautomator2.server'
[ADB] Checking app cert for C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk
[ADB] Using apksigner.bat from C:\Program Files\Android\SDK\build-tools\28.0.2\apksigner.bat
[ADB] Starting 'C:\Program Files\Android\SDK\build-tools\28.0.2\apksigner.bat' with args 'verify,--print-certs,C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk'
[ADB] 'C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk' is not signed with debug cert.
[ADB] Zip-aligning 'C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk'
[ADB] Checking whether zipalign is present
[ADB] Using zipalign.exe from C:\Program Files\Android\SDK\build-tools\28.0.2\zipalign.exe
[ADB] Signing 'C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk' with default cert
[ADB] Starting 'C:\Program Files\Android\SDK\build-tools\28.0.2\apksigner.bat' with args 'sign,--key,C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-adb\keys\testkey.pk8,--cert,C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-adb\keys\testkey.x509.pem,C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk'
[ADB] Cannot use apksigner tool for signing. Defaulting to sign.jar. Original error: Command ''C:\\Program Files\\Android\\SDK\\build-tools\\28.0.2\\apksigner.bat' sign --key 'C:\\Program Files (x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-adb\\keys\\testkey.pk8' --cert 'C:\\Program Files (x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-adb\\keys\\testkey.x509.pem' 'C:\\Program Files (x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-v1.12.0.apk'' exited with code 1; StdErr: 'C:\Program' is not recognized as an internal or external command,
[ADB] operable program or batch file.
[ADB]
[ADB] Resigning apk.
[UiAutomator2] Deleting UiAutomator2 session
[UiAutomator2] Deleting UiAutomator2 server session
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: Error: Trying to proxy a session command without session id
[ADB] Running 'C:\Program Files\Android\SDK\platform-tools\adb.exe -P 5037 -s SOVW6PUS99999999 shell am force-stop base.apk'
[ADB] Removing forwarded port socket connection: 8200
[ADB] Running 'C:\Program Files\Android\SDK\platform-tools\adb.exe -P 5037 -s SOVW6PUS99999999 forward --remove tcp\:8200'
[ADB] Running 'C:\Program Files\Android\SDK\platform-tools\adb.exe -P 5037 -s SOVW6PUS99999999 forward --remove tcp\:8200'
[UiAutomator2] Unable to remove port forward 'Error executing adbExec. Original error: 'Command ''C:\\Program Files\\Android\\SDK\\platform-tools\\adb.exe' -P 5037 -s SOVW6PUS99999999 forward --remove tcp\:8200' exited with code 1'; Stderr: 'error: listener 'tcp:8200' not found'; Code: '1''
[BaseDriver] Event 'newSessionStarted' logged at 1534424157559 (19:55:57 GMT+0700 (SE Asia Standard Time))
[MJSONWP] Encountered internal error running command: Error: Could not sign with default certificate. Original error Command ''C:\\Program Files\\Java\\jdk1.8.0_181\\bin\\java.exe' -jar 'C:\\Program Files (x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-adb\\jars\\sign.jar' 'C:\\Program Files (x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-v1.12.0.apk' --override' exited with code 1
EDIT, SOLVED:
Thanks to Ross I've found out where the problem is.
I've solved it by changing the path of ANDROID_HOME and JAVA_HOME from C:\Program Files\ to C:\PROGRA~1\ like it said here.
Just run appium as admin and your problem will be solved. I have also been facing the same problem. I have searched and come to know that no need to change the path variables address.
Follow these steps:
Run appium as admin.
Before starting server, click options Advanced and checkbox mark Allow Session Override.
This problem can be resolved, by properly setting desiredCapabilities. Generally we specify automationName as uiautomator2. The moment we right this error is thrown.
Exact desiredCapability would be like this, "automatorName" text "UiAutomator2"
there is another property which is used to skip the signing process in appium desktop.
"noSign" "true"
use these two desiredCapabilities together it will work fine.

Appium path issue

I'm trying to run an apk file from my test suite in appium, the emulator runs successfully but at the time of launch of the apk it says apk not found. The path looks correct to me still unable to figure out the solution.
Below is the error from Appium.
AndroidDriver] Using device: emulator-5554
[ADB] Checking whether adb is present
[ADB] Using adb from /Library/Android/sdk/platform-tools/adb
[debug] [ADB] Setting device id to emulator-5554
[BaseDriver] Using local app '/src/test/resources/myapp.apk'
[debug] [AndroidDriver] Checking whether app is actually present
[debug] [AndroidDriver] Shutting down Android driver
[AndroidDriver] Cannot shut down Android driver; it has already shut down
[HTTP] <-- POST /wd/hub/session 500 25028 ms - 212
[AndroidDriver] Error: Could not find app apk at /src/test/resources/myapp.apk
at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)
at AndroidDriver.checkAppPresent$ (lib/driver.js:274:11)
at tryCatch (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at run (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:104:47)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:115:28
at flush (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/$.microtask.js:19:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
[Error: Could not find app apk at /src/test/resources/myapp.apk]
I tried following path apart from the one listed above:
1. ./src/test
2. Start from the module name which is part of /src/test i.e. modulename/src/test
3. Tried ~./src/test
4. Tried ~/src/test
Any pointers as to what is it that I'm missing?
Also, why am I getting this ([debug] [AndroidDriver] Shutting down Android driver) before the apk launch?
Code:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.FULL_RESET,"true");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Nexus10");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,"4.4");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");
capabilities.setCapability(MobileCapabilityType.APP,"myapp.package");
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "20");
capabilities.setCapability("app", "/src/test/resources/myapp.apk");
AndroidDriver = new AndroidDriver(new URL("http://127.0.0.1:4724/wd/hub"), capabilities);
AndroidDriver.rotate(ScreenOrientation.PORTRAIT);
log.info("Set up done for capabilities");
Thanks in advance.
If the 'src' folder is in the same location as you're running from, you want to remove the preceding '/' as that's telling Appium to look starting at the root of the entire file system rather than from your local path.
src/test/resources/myapp.apk
My experience is that using '~' does not work with Appium. I personally have parameterized the app location and pull it from an environment variable to account for it being in different places on different systems, but in all cases I provide the path from the file system root as it's simplest.

Appium Chrome driver port 9515

I am able to execute the script for the first with appium, selenium and C# on android device. But whenever I try to run the script next time I am getting below error.
info: [CHROMEDRIVER STDERR] [0.028][SEVERE]: Could not bind socket to 0.0.0.0:9515
info: [CHROMEDRIVER] Port not available. Exiting...
info: Chromedriver exited with code 1
ERROR: debug: executing: "c:\android-sdk\platform-tools\adb.exe" -s 4d00b33d4ae241bf devices
info: [ADB] Getting connected devices...
info: [ADB] 1 device(s) connected
ERROR: debug: executing: "c:\android-sdk\platform-tools\adb.exe" -s 4d00b33d4ae241bf shell "am force-stop com.android.chrome"
ERROR: error: Chromedriver create session did not work. Status was 200 and body was {"sessionId":"79cdf9fec37fb4700e10ce34566a7e11","status":13,"value":{"message":"unknown error: Device 4d00b33d4ae241bf is already in use\n (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)"}}
ERROR: error: Failed to start an Appium session, err was: Error: Did not get session redirect from Chromedriver
But if I change the Chrome driver port from 9515 to something else the script is getting executed. Then againw henever I want to execute the script, I have to change the Chrome driver port to something new from the existing one. My OS is windows 7. Need help in this matter.
I think you are not closing the driver instance after the script run so the acquired port is not free for next run.
Possible Solutions:
Findout the process of Chromedriver and stop it
Restart Appium server
Try with driver.quit() or equivalent at the end point of your script

Resources