Coder Social home page Coder Social logo

Can't start Appium Inspector - Error: Failed to create session. Bad capabilities. Specify either app or appTopLevelWindow to create a session about appium HOT 12 CLOSED

kenzoviski avatar kenzoviski commented on June 9, 2024
Can't start Appium Inspector - Error: Failed to create session. Bad capabilities. Specify either app or appTopLevelWindow to create a session

from appium.

Comments (12)

mykola-mokhnach avatar mykola-mokhnach commented on June 9, 2024 1

I'm sorry to hear that, but yes, MS has its own plans regarding windows automation and open sourcing policies in general.

Closed as not an issue.

from appium.

eglitise avatar eglitise commented on June 9, 2024

Any Appium session will always require the platformName and appium:automationName capabilities, both of which are missing in your case. Check the Windows driver documentation.
If you still see this error after adding the above two capabilities, please provide your Appium server log.

from appium.

kenzoviski avatar kenzoviski commented on June 9, 2024

Any Appium session will always require the platformName and appium:automationName capabilities, both of which are missing in your case. Check the Windows driver documentation. If you still see this error after adding the above two capabilities, please provide your Appium server log.

So I edited the capabilities to this:
{
"appium:app": "D:\Trabalho Freelancer\FLOWApps\Applications\FLOW2BO\flow2bo.exe",
"platformName": "windows",
"appium:automationName": "windows"
}

And when I click "Start Session" I get the same error:
"Error Failed to create session. Bad capabilities. Specify either app or appTopLevelWindow to create a session"

Where do I find the server logs (I'm new to Appium sorry for the dumb question)? I can't "Start session" through Appium Inspector GUI, I only get the above error. From what I've searched, logs are created when I already have a session, but I can't even pass that.

On WinAppDriver I got this log:

==========================================
POST /session HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate, br
Accept-Language: pt-PT
Connection: keep-alive
Content-Length: 504
Content-Type: application/json
Host: 127.0.0.1:4723
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) appium-inspector/2024.3.1 Chrome/91.0.4472.164 Electron/13.6.9 Safari/537.36

{"capabilities":{"alwaysMatch":{"appium:app":"D:\Trabalho Freelancer\FLOWApps\Applications\FLOW2BO\flow2bo.exe","platformName":"windows","appium:automationName":"windows","appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true},"firstMatch":[{}]},"desiredCapabilities":{"appium:app":"D:\Trabalho Freelancer\FLOWApps\Applications\FLOW2BO\flow2bo.exe","platformName":"windows","appium:automationName":"windows","appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true}}
HTTP/1.1 400 Bad Request
Content-Length: 141
Content-Type: application/json

{"status":100,"value":{"error":"invalid argument","message":"Bad capabilities. Specify either app or appTopLevelWindow to create a session"}}

from appium.

eglitise avatar eglitise commented on June 9, 2024

Logs will be created in the terminal window where you have launched the Appium server. What versions of the Appium server / Windows driver / WinAppDriver are you using?

from appium.

mykola-mokhnach avatar mykola-mokhnach commented on June 9, 2024

It won't work if you use WAD directly without appium-windows-driver. The error above happens because inspector sends W3C capabilities, which WAD does not understand (and probably won't because MS does not really care about maintaining it). appium-windows-driver works as a proxy and translates W3C commands into JWP ones understandable for the server.

from appium.

kenzoviski avatar kenzoviski commented on June 9, 2024

Logs will be created in the terminal window where you have launched the Appium server. What versions of the Appium server / Windows driver / WinAppDriver are you using?

It won't work if you use WAD directly without appium-windows-driver. The error above happens because inspector sends W3C capabilities, which WAD does not understand (and probably won't because MS does not really care about maintaining it). appium-windows-driver works as a proxy and translates W3C commands into JWP ones understandable for the server.

My Appium Server version through command: appium --version
2.5.1

Appium Inspector (latest release on github): 2024.3.1

My Windows driver installed (https://www.npmjs.com/package/appium-windows-driver) through command: appium driver install --source=npm appium-windows-driver
[email protected] [installed (npm)]

WinAppDriver (latest release candidate) installed on Windows 11: WinAppDriver v1.3 Release Candidate 1 (1.2.99)

On VS Code bash terminal I start Appium: appium -a 127.0.0.1 -p 4723

And get the following log/error:

[Appium] Welcome to Appium v2.5.1
[Appium] Non-default server args:
[Appium] {
[Appium]   address: '127.0.0.1'
[Appium] }
[Appium] The autodetected Appium home path: D:\Trabalho Freelancer\FlowAutomation\DesktopAutomationCSharp
[Appium] Attempting to load driver windows...
[Appium] Requiring driver at D:\Trabalho Freelancer\FlowAutomation\DesktopAutomationCSharp\node_modules\appium-windows-driver\build\index.js
[Appium] Could not load driver 'windows', so it will not be available. Error in loading the driver was: Unexpected External value as type specifier, expected string or type
[Appium] TypeError: Unexpected External value as type specifier, expected string or type
[Appium]     at Object.<anonymous> (D:\Trabalho Freelancer\FlowAutomation\DesktopAutomationCSharp\node_modules\appium-windows-driver\lib\commands\winapi\user32.js:102:49)
[Appium]     at Module._compile (node:internal/modules/cjs/loader:1378:14)
[Appium]     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1437:10)
[Appium]     at Module.load (node:internal/modules/cjs/loader:1212:32)
[Appium]     at Function.Module._load (node:internal/modules/cjs/loader:1028:12)
[Appium]     at Module.require (node:internal/modules/cjs/loader:1237:19)
[Appium]     at require (node:internal/modules/helpers:176:18)
[Appium]     at Object.<anonymous> (D:\Trabalho Freelancer\FlowAutomation\DesktopAutomationCSharp\node_modules\appium-windows-driver\lib\commands\gestures.js:2:1)
[Appium]     at Module._compile (node:internal/modules/cjs/loader:1378:14)
[Appium]     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1437:10)
[Appium]     at Module.load (node:internal/modules/cjs/loader:1212:32)
[Appium]     at Function.Module._load (node:internal/modules/cjs/loader:1028:12)
[Appium]     at Module.require (node:internal/modules/cjs/loader:1237:19)
[Appium]     at require (node:internal/modules/helpers:176:18)
[Appium]     at Object.<anonymous> (D:\Trabalho Freelancer\FlowAutomation\DesktopAutomationCSharp\node_modules\appium-windows-driver\lib\commands\index.js:9:1)
[Appium]     at Module._compile (node:internal/modules/cjs/loader:1378:14)
[Appium]     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1437:10)
[Appium]     at Module.load (node:internal/modules/cjs/loader:1212:32)
[Appium]     at Function.Module._load (node:internal/modules/cjs/loader:1028:12)
[Appium]     at Module.require (node:internal/modules/cjs/loader:1237:19)
[Appium]     at require (node:internal/modules/helpers:176:18)
[Appium]     at Object.<anonymous> (D:\Trabalho Freelancer\FlowAutomation\DesktopAutomationCSharp\node_modules\appium-windows-driver\lib\driver.js:6:1)
[Appium]     at Module._compile (node:internal/modules/cjs/loader:1378:14)
[Appium]     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1437:10)
[Appium]     at Module.load (node:internal/modules/cjs/loader:1212:32)
[Appium]     at Function.Module._load (node:internal/modules/cjs/loader:1028:12)
[Appium]     at Module.require (node:internal/modules/cjs/loader:1237:19)
[Appium]     at require (node:internal/modules/helpers:176:18)
[Appium] Appium REST http interface listener started on http://127.0.0.1:4723
[Appium] Available drivers:
[Appium]   - [email protected] (automationName 'Windows')
[Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use.

It says "- [email protected] (automationName 'Windows')" is an available driver but can't start it.
I'm confused now... I usally execute WinAppDriver.exe through cmd and let it run. I though Appium would connect to it but it doesn't seem to be the case.

Also enabled developer mode in Windows 11.
How do I test desktop apps using Appium and WinAppDriver then?

from appium.

mykola-mokhnach avatar mykola-mokhnach commented on June 9, 2024

Check #19659

from appium.

kenzoviski avatar kenzoviski commented on June 9, 2024

Check #19659

After installing Node.js_20.11.1 LTS I managed to start Appium server successfully.
But still, I'm getting an error while executing the Appium Inspector when I click on "Start Sessions".

These are my "Capabilities":

{
  "appium:app": "D:\\Trabalho Freelancer\\FLOWApps\\Applications\\FLOW2BO\\flow2bo.exe",
  "platformName": "windows",
  "appium:automationName": "windows"
}

And I'm starting Appium server with the following command: appium --address 127.0.0.1 --port 4723

And on Appium server I get the following error:

Appium] Attempting to find matching driver for automationName 'windows' and platformName 'windows'
[Appium] The 'windows' driver was installed and matched caps.
[Appium] Will require it at D:\Trabalho Freelancer\FlowAutomation\node_modules\appium-windows-driver
[Appium] Requiring driver at D:\Trabalho Freelancer\FlowAutomation\node_modules\appium-windows-driver\build\index.js
[AppiumDriver@ce67] Appium v2.5.1 creating new WindowsDriver (v2.12.18) session
[AppiumDriver@ce67] Checking BaseDriver versions for Appium and WindowsDriver
[AppiumDriver@ce67] Appium's BaseDriver version is 9.5.2
[AppiumDriver@ce67] WindowsDriver's BaseDriver version is 9.5.2
[WindowsDriver@1b02] Creating session with W3C capabilities: {
[WindowsDriver@1b02]   "alwaysMatch": {
[WindowsDriver@1b02]     "platformName": "windows",
[WindowsDriver@1b02]     "appium:app": "D:\\Trabalho Freelancer\\FLOWApps\\Applications\\FLOW2BO\\flow2bo.exe",
[WindowsDriver@1b02]     "appium:automationName": "windows",
[WindowsDriver@1b02]     "appium:newCommandTimeout": 3600,
[WindowsDriver@1b02]     "appium:connectHardwareKeyboard": true
[WindowsDriver@1b02]   },
[WindowsDriver@1b02]   "firstMatch": [
[WindowsDriver@1b02]     {}
[WindowsDriver@1b02]   ]
[WindowsDriver@1b02] }
[WindowsDriver@1b02] The following provided capabilities were not recognized by this driver:
[WindowsDriver@1b02]   connectHardwareKeyboard
[WindowsDriver@1b02 (b60ea8e7)] Session created with session id: b60ea8e7-b05f-43be-8842-6051c26c16bf
[WindowsDriver@1b02 (b60ea8e7)] Spawning 'C:\Program Files\Windows Application Driver\WinAppDriver.exe' with args: ["4724/wd/hub"]
[WindowsDriver@1b02 (b60ea8e7)] Matched '/status' to command name 'getStatus'
[WindowsDriver@1b02 (b60ea8e7)] Proxying [GET /status] to [GET http://127.0.0.1:4724/wd/hub/status] with no body
[WindowsDriver@1b02 (b60ea8e7)] connect ECONNREFUSED 127.0.0.1:4724
[WindowsDriver@1b02 (b60ea8e7)] Windows Application Driver listening for requests at: http://127.0.0.1:4724/wd/hub
[WindowsDriver@1b02 (b60ea8e7)] Press ENTER to exit.
[WindowsDriver@1b02 (b60ea8e7)] Matched '/status' to command name 'getStatus'
[WindowsDriver@1b02 (b60ea8e7)] Proxying [GET /status] to [GET http://127.0.0.1:4724/wd/hub/status] with no body
[WindowsDriver@1b02 (b60ea8e7)] ==========================================
[WindowsDriver@1b02 (b60ea8e7)] GET /wd/hub/status HTTP/1.1
[WindowsDriver@1b02 (b60ea8e7)] Accept: application/json, */*
[WindowsDriver@1b02 (b60ea8e7)] Accept-Encoding: gzip, compress, deflate, br
[WindowsDriver@1b02 (b60ea8e7)] Connection: keep-alive
[WindowsDriver@1b02 (b60ea8e7)] Content-Type: application/json; charset=utf-8
[WindowsDriver@1b02 (b60ea8e7)] Host: 127.0.0.1:4724
[WindowsDriver@1b02 (b60ea8e7)] User-Agent: appium
[WindowsDriver@1b02 (b60ea8e7)] Got response with status 500: {"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}
[W3C] Matched W3C error code 'unknown error' to UnknownError

Appium inspector gives the error:
Failed to create session. An unknown server-side error occurred while processing the command. Original error: WinAppDriver server is not listening within 10000ms timeout. Make sure it could be started manually

OpenQA.Selenium.WebDriverException : An unknown server-side error occurred while processing the command. Original error: WinAppDriver server is not listening within 10000ms timeout. Make sure it could be started manually
   at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Appium.AppiumDriver`1.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
   at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
   at OpenQA.Selenium.Appium.AppiumDriver`1..ctor(ICommandExecutor commandExecutor, ICapabilities appiumOptions)
   at OpenQA.Selenium.Appium.AppiumDriver`1..ctor(Uri remoteAddress, ICapabilities appiumOptions, TimeSpan commandTimeout)
   at OpenQA.Selenium.Appium.AppiumDriver`1..ctor(Uri remoteAddress, ICapabilities appiumOptions)
   at OpenQA.Selenium.Appium.Windows.WindowsDriver`1..ctor(Uri remoteAddress, AppiumOptions AppiumOptions)
   at FlowAutomation.Tests.Test1() in D:\Trabalho Freelancer\FlowAutomation\test\specs\test1.cs:line 27
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

How do I fix this, so I can hook my app to Appium Inspector and start identifying the elements on my desktop app (flow2bo)?

from appium.

mykola-mokhnach avatar mykola-mokhnach commented on June 9, 2024

This is an issue with the server itself. Try https://github.com/appium/appium-windows-driver?tab=readme-ov-file#various-winappdriver-calls-dont-work-as-expected-or-throw-weird-errors

from appium.

kenzoviski avatar kenzoviski commented on June 9, 2024

This is an issue with the server itself. Try https://github.com/appium/appium-windows-driver?tab=readme-ov-file#various-winappdriver-calls-dont-work-as-expected-or-throw-weird-errors

Well, that didn't help at all.
Since it's a problem related directly to WinAppDriver, I opened an issue on their repo and refering this issue.

I just don't understand how people test desktop apps on Windows. I suppose no one test them at all or have to pay thousands for a software that does the job. Going open-source on Windows is not a good idea.

from appium.

mykola-mokhnach avatar mykola-mokhnach commented on June 9, 2024

Well, that didn't help at all.

What exactly have you tried? Did you try it with a different WAD version?

from appium.

kenzoviski avatar kenzoviski commented on June 9, 2024

Well, that didn't help at all.

What exactly have you tried? Did you try it with a different WAD version?

Yes, I installed the previous version of WAD and Appium Inspector hooked to my app. No errors on Appium Server.
Although, I realized it can't identify all the elements on my desktop app. It's not a suitable solution to automate tests, at least on the app I'm trying to test.

Guess I have to go for a paid software that has a better "Spy tool", like Ranorex.

from appium.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.