org.openqa.selenium.WebDriverException: An unknown server-side error occurred - appium

Configured with appium and eclipse in mac.
Almost set Android_home and java_home in appium configuration
Set capabilities in selenium
And set driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
Once run selenium shown exception error as:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Command 'java -version' exited with code 2
In appium server shown as:
[W3C] Encountered internal error running command: Error: Command 'java -version' exited with code 2
Here is the code:
DesiredCapabilities capabilities = new DesiredCapabilities();
String apkpath="apk/path";
File app=new File(apkpath);
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("deviceName","G2AXB711Y044HV6");
capabilities.setCapability(CapabilityType.VERSION, "6.0.1");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("appPackage", "com.ABC");
capabilities.setCapability("appActivity", "com.ABC.Activity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);`enter code here`
[W3C] at ChildProcess.proc.on.code
(/Applications/Appium.app/Contents/Resources/app/node_modules/teen_process/lib/exec.js:94:19)
[W3C] at ChildProcess.emit (events.js:182:13)
[W3C] at maybeClose (internal/child_process.js:961:16)
[W3C] at Socket.stream.socket.on (internal/child_process.js:380:11)
[W3C] at Socket.emit (events.js:182:13)
[W3C] at Pipe._handle.close [as _onclose] (net.js:596:12)
Please suggest any solution?

Related

Cannot read properties of undefined (reading 'match') appium flutter driver

\[debug] [FlutterDriver] Deleting Flutter Driver session[debug] [BaseDriver] Event 'newSessionStarted' logged at 1672668476064 (19:07:56 GMT+0500 (Pakistan Standard Time))[debug] [W3C] Encountered internal error running command: TypeError: Cannot read properties of undefined (reading 'match')[debug] [W3C] at Object.exports.processLogToGetobservatory (C:\Users\asad.sidhu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-flutter-driver\build\driver\lib\sessions\observatory.js:118:9)[debug] [W3C] at Object.exports.getObservatoryWsUri (C:\Users\asad.sidhu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-flutter-driver\lib\sessions\android.ts:39:21)[debug] [W3C] at Object.exports.startAndroidSession (C:\Users\asad.sidhu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-flutter-driver\lib\sessions\android.ts:26:30)[debug] [W3C] at processTicksAndRejections (node:internal/process/task_queues:95:5)[debug] [W3C] at FlutterDriver.exports.createSession (C:\Users\asad.sidhu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-flutter-driver\lib\sessions\session.ts:21:47)[debug] [W3C] at AppiumDriver.createSession (C:\Users\asad.sidhu\AppData\Roaming\npm\node_modules\appium\lib\appium.js:387:35)[HTTP] <-- POST /wd/hub/session 500 16629 ms - 677[HTTP][debug] [Instrumentation] The process has exited with code 0
When I try to run my java automation code with appium flutter driver, it gives me this error. \*\*Cannot read properties of undefined (reading 'match') appium flutter driver \*\* Please help, I have been stuck with this problem for a couple of days!!! Here are the appium logs:
I expected the tests to open the app, find the elements by valuekeys and interact with them, but the app installs, opens and crashes on start up.`

Could not find a driver for automationName 'XCUITest' and platformName 'iOS'. Please check your desired capabilities

I've searched a lot about this error. I've done a lot of tutorials and nothing works:
I've created a test iOS project and it seems that I have everything installed to start working with appium in iOS
bacelar#Brunos-MacBook-Pro-2 Test % appium-doctor --ios
info AppiumDoctor Appium Doctor v.1.15.1
info AppiumDoctor ### Diagnostic for necessary dependencies starting ###
info AppiumDoctor ✔ The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor ✔ Node version is 12.13.1
info AppiumDoctor ✔ Xcode is installed at: /Applications/Xcode.app/Contents/Developer
info AppiumDoctor ✔ Xcode Command Line Tools are installed in: /Applications/Xcode.app/Contents/Developer
info AppiumDoctor ✔ DevToolsSecurity is enabled.
info AppiumDoctor ✔ The Authorization DB is set up properly.
info AppiumDoctor ✔ Carthage was found at: /usr/local/bin/carthage. Installed version is: 0.34.0
info AppiumDoctor ✔ HOME is set to: /Users/bacelar
info AppiumDoctor ### Diagnostic for necessary dependencies completed, no fix needed. ###
But when I start inspector session on appium desktop I get the following error:
Encountered internal error running command: Error: Could not find a driver for automationName 'XCUITest' and platformName 'iOS'. Please check your desired capabilities.
Here is the appium log:
[HTTP] {"desiredCapabilities":{"app":"/Users/bacelar/Curatio/automatedTests/iOS/test_project/Test/build/Release-iphonesimulator/Test.app","automationName":"XCUITest","deviceName":"iphone 11","noReset":true,"platformName":"iOS","platformVersion":"13.4","newCommandTimeout":0,"connectHardwareKeyboard":true}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"/Users/bacelar/Curatio/automatedTests/iOS/test_project/Test/build/Release-iphonesimulator/Test.app","automationName":"XCUITest","deviceName":"iphone 11","noReset":true,"platformName":"iOS","platformVersion":"13.4","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null]
[BaseDriver] Event 'newSessionRequested' logged at 1588813098829 (17:58:18 GMT-0700 (PDT))
[BaseDriver] Event 'newSessionStarted' logged at 1588813098836 (17:58:18 GMT-0700 (PDT))
[MJSONWP] Encountered internal error running command: Error: Could not find a driver for automationName 'XCUITest' and platformName 'iOS'. Please check your desired capabilities.
[MJSONWP] at AppiumDriver.getDriverAndVersionForCaps (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/lib/appium.js:226:11)
[MJSONWP] at AppiumDriver.getDriverAndVersionForCaps [as createSession] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/lib/appium.js:300:66)
[MJSONWP] at AppiumDriver.executeCommand (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:376:19)
[MJSONWP] at AppiumDriver.executeCommand (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/lib/appium.js:482:26)
[MJSONWP] at executeCommand (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:306:34)
[MJSONWP] at asyncHandler (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:432:15)
[MJSONWP] at Layer.handle [as handle_request] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/layer.js:95:5)
[MJSONWP] at next (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/route.js:137:13)
[MJSONWP] at Route.dispatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/route.js:112:3)
[MJSONWP] at Layer.handle [as handle_request] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/layer.js:95:5)
[MJSONWP] at /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/index.js:281:22
[MJSONWP] at Function.process_params (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/index.js:335:12)
[MJSONWP] at next (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/index.js:275:10)
[MJSONWP] at logger (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/morgan/index.js:144:5)
[MJSONWP] at Layer.handle [as handle_request] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/layer.js:95:5)
[MJSONWP] at trim_prefix (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/index.js:317:13)
[MJSONWP] at /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/index.js:284:7
[MJSONWP] at Function.process_params (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/index.js:335:12)
[MJSONWP] at next (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/index.js:275:10)
[MJSONWP] at /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/body-parser/lib/read.js:130:5
[MJSONWP] at invokeCallback (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/raw-body/index.js:224:16)
[MJSONWP] at done (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/raw-body/index.js:213:7)
[MJSONWP] at IncomingMessage.onEnd (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/raw-body/index.js:273:7)
[MJSONWP] at IncomingMessage.emit (events.js:182:13)
[MJSONWP] at endReadableNT (_stream_readable.js:1090:12)
[MJSONWP] at process._tickCallback (internal/process/next_tick.js:63:19)
[HTTP] <-- POST /wd/hub/session 500 11 ms - 254
[HTTP]
[HTTP] --> DELETE /wd/hub/session
[HTTP] {}
[HTTP] No route found. Setting content type to 'text/plain'
[HTTP] <-- DELETE /wd/hub/session 404 1 ms - 57
[HTTP]
What should be done to fix it?
I think the values that you pass in your desired capabilities for deviceName, platformName, platformVersion should match to a simulator that is there in your Xcode so that appium can find and start it.
The below set of capabilities has worked for me in the past:
File demoAppPath = new File("Demo App");
File demoApp = new File(demoAppPath, "Demo.app");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.APP, demoApp.getAbsolutePath());
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 8");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "IOS");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "13.2");
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.IOS_XCUI_TEST);
Note that i had a simulator in my Xcode with the name iPhone 8 and has the iOS version 13.2. Hope it helps !!
After long hours searching I found a way to solve it.
The desires capabilities needs to be:
"xcodeOrgId": "XXXXXXXXX",
"xcodeSigningId": "iPhone Developer",
"udid": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"platformName": "iOS",
"deviceName": "DEVICE NAME",
"bundleId": "BUNDLE ID",
"automationName": "XCUITest"
Executing the steps from this tutorial:
https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md
I was getting errors and after executing this command on terminal
security unlock-keychain -p ****
Everything is working, I can inspect my app and run my automated tests.
Hope it helps if you are getting the same issue.
I faced this issue and looked at many solutions, but none that worked. Finally, I updated Appium desktop to v1.18.3 and Appium CLI to v1.19.1. It really works. So, it may be version bug.

Error: 'null' cannot be coerced to a valid version number

Appium server is showing the 'null' cannot be coerced to a valid version number error.
Following are DesiredCapabilities that i have used
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.UDID, udid);
caps.setCapability(MobileCapabilityType.NO_RESET, noReset);
caps.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 600);
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.IOS);
caps.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone");
caps.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
caps.setCapability("xcodeOrgId", myXcodeOrgId);
caps.setCapability("xcodeSigningId", "iPhone Developer");
caps.setCapability("showXcodeLog", true);
driver = new IOSDriver(new URL("http://" + host + ":" + port + "/wd/hub"), caps);
Following is the appium server log:
Creating session with W3C capabilities: {"alwaysMatch":{"platformNa...
[BaseDriver] Session created with session id: 77cbca4b-157d-462e-ab26-5cc9cc47c7a9
[debug] [XCUITest] Current user: 'infotmt'
[XCUITest] Error: 'null' cannot be coerced to a valid version number
[XCUITest] at coerceVersion (/usr/local/lib/node_modules/appium/node_modules/appium-support/lib/util.js:241:11)
[XCUITest] at Object.coerceVersion [as compareVersions] (/usr/local/lib/node_modules/appium/node_modules/appium-support/lib/util.js:268:35)
[XCUITest] at XCUITestDriver.compareVersions [as start] (/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:263:14)
[debug] [XCUITest] Not clearing log files. Use `clearSystemFiles` capability to turn on.
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1553847186978 (13:58:06 GMT+0545 (Nepal Time))
[debug] [W3C] Encountered internal error running command: Error: 'null' cannot be coerced to a valid version number
[debug] [W3C] at coerceVersion (/usr/local/lib/node_modules/appium/node_modules/appium-support/lib/util.js:241:11)
[debug] [W3C] at Object.coerceVersion [as compareVersions] (/usr/local/lib/node_modules/appium/node_modules/appium-support/lib/util.js:268:35)
[debug] [W3C] at XCUITestDriver.compareVersions [as start] (/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:263:14)
[HTTP] <-- POST /wd/hub/session 500 29 ms - 597
[HTTP]
I am using
Appium server version - 1.12.1
Java client Version - 7.0.0
In Appium 1.12.1 the platformVersion must be set. Code to be added:
caps.setCapability("platformVersion", "12.2");
The 12.2 is the version of the iOS.

Not able to launch iOS application using Appium Desktop to inspect the element

Test Environment: iOS 11, OSX 10.12, Appium Desktop 1.2.5, Xcode 8.1
Desired Capabilities :
{
"platformName": "iOS",
"deviceName": "iPhone 7",
"udid": "93551a7d721b790b0188642402f1ada96892b816",
"app": "/Users/globalit/Desktop/IntegrationApp.app",
"automationName": "XCUITest"
}
I am able to launch integration app in the device using xcode.
also successfully deployed web-driver agent in my device.
But i am getting following error when i tried to launch my ios application via appium desktop.
Error:
An unknown server-side error occurred while processing the command. Original error: Unable to start WebDriverAgent session because of xcodebuild failure: "Could not proxy command to remote server. Original error: Error: socket hang up". Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
Appium Logs:
XCUITest] Failed to create WDA session. Retrying...
[BaseDriver] Event 'wdaSessionAttempted' logged at 1509096179356 (14:52:59 GMT+0530 (IST))
[XCUITest] Sending createSession command to WDA
[JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[XCUITest] Failed to create WDA session. Retrying...
[XCUITest] Unable to start WebDriverAgent session because of xcodebuild failure: "Could not proxy command to remote server. Original error: Error: socket hang up". Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
[XCUITest] Quitting and uninstalling WebDriverAgent, then retrying
[XCUITest] Shutting down sub-processes
[XCUITest] Shutting down iproxy process (pid 576)
[XCUITest] iproxy exited with code 'null'
[XCUITest] Shutting down xcodebuild process (pid 577)
[XCUITest] xcodebuild exited with code 'null' and signal 'SIGTERM'
[XCUITest] Removing WDA application from device
[XCUITest] Error: Unable to start WebDriverAgent session because of xcodebuild failure: "Could not proxy command to remote server. Original error: Error: socket hang up". Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
at XCUITestDriver.quitAndUninstall$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:381:13)
at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
Error: Unable to start WebDriverAgent session because of xcodebuild failure: "Could not proxy command to remote server. Original error: Error: socket hang up". Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
at XCUITestDriver.quitAndUninstall$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:381:13)
at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[XCUITest] Not clearing log files. Use `clearSystemFiles` capability to turn on.
[iOSLog] Stopping iOS log capture
[MJSONWP] Encountered internal error running command: Error: Unable to start WebDriverAgent session because of xcodebuild failure: "Could not proxy command to remote server. Original error: Error: socket hang up". Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
at XCUITestDriver.quitAndUninstall$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:381:13)
at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[HTTP] <-- POST /wd/hub/session 500 118446 ms - 526

org.openqa.selenium.remote.SessionNotFoundException: no such session

I am trying to automate mobile web automation test cases on android phone but I am getting the below error:-
org.openqa.selenium.remote.SessionNotFoundException: no such session
(Driver info: chromedriver=2.21.371461 (633e689b520b25f3e264a2ede6b74ccc23cb636a),platform=Linux 3.16.0-77-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 12 milliseconds
Please see the below code snippet:
ChromeOptions c=new ChromeOptions();
DesiredCapabilities dc = DesiredCapabilities.chrome();
dc.setCapability("browserName", "chrome");
dc.setCapability("appium-version", "1.6.0");
dc.setCapability("deviceName", "4d00b83ed4f7426f");
dc.setCapability(CapabilityType.VERSION, "5.0.1");
dc.setCapability("platformName", "Android");
dc.setCapability(ChromeOptions.CAPABILITY, c);
dc.setCapability("appPackage", "com.android.chrome");
dc.setCapability("appActivity", "com.google.android.apps.chrome.document.ChromeLauncherActivity");
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), dc);
driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);
In Appium server logs I am getting below error:
[ADB] Error: Unable to get pids for uiautomator. Orginial error: this.shell(...).trim is not a function at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13) at ADB.callee$0$0$ (lib/tools/adb-commands.js:441:9) at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runti‌​me/regenerator/runti‌​me.js:67:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runti‌​me/regenerator/runti‌​me.js:315:22)
Usually this error comes up when:
Appium Server is not running
Connection with the Appium server is lost for any reason
Appium server misconfigured.
Make sure you have your Appium GUI app open and have a look at its console when the execution starts. You should see that the server is at least is up and getting your request. The from the log, try to see why it fails. If there is no response in Appium console and it just stays unchanged, that means that your configuration is wrong. Perhaps you are using an incorrect port.

Resources