appium / appium-windows-driver

Appium's interface to WindowsAppDriver provided by Microsoft
Apache License 2.0
125 stars 35 forks source link

appWorkingDir fails for shortcut #117

Open Alek5andr opened 2 years ago

Alek5andr commented 2 years ago

Hi!

Test run fails with message:

DEBUG webdriver: request failed due to response error: unknown error
ERROR webdriver: Request failed with status 500 due to unknown error: An unknown server-side error occurred while processing the command. Original error:
 The system cannot find the file specified
ERROR webdriver: unknown error: An unknown server-side error occurred while processing the command. Original error: The system cannot find the file speci
fied
    at Object.getErrorFromResponseBody (C:\Users\User\IdeaProjects\lennuk-ui\node_modules\webdriverio\node_modules\webdriver\build\utils.js:94:12)
    at WebDriverRequest._request (C:\Users\User\IdeaProjects\lennuk-ui\node_modules\webdriverio\node_modules\webdriver\build\request.js:134:31)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at Object.startWebDriverSession (C:\Users\User\IdeaProjects\lennuk-ui\node_modules\webdriverio\node_modules\webdriver\build\utils.js:29:20)
    at Function.newSession (C:\Users\User\IdeaProjects\lennuk-ui\node_modules\webdriverio\node_modules\webdriver\build\index.js:35:45)
    at Object.exports.remote (C:\Users\User\IdeaProjects\lennuk-ui\node_modules\webdriverio\build\index.js:53:22)
    at Runner._startSession (C:\Users\User\IdeaProjects\lennuk-ui\node_modules\@wdio\runner\build\index.js:123:56)
    at Runner._initSession (C:\Users\User\IdeaProjects\lennuk-ui\node_modules\@wdio\runner\build\index.js:103:25)
    at Runner.run (C:\Users\User\IdeaProjects\lennuk-ui\node_modules\@wdio\runner\build\index.js:52:19)
ERROR @wdio/runner: Error: Failed to create session.
An unknown server-side error occurred while processing the command. Original error: The system cannot find the file specified
    at Object.startWebDriverSession (C:\Users\User\IdeaProjects\lennuk-ui\node_modules\webdriverio\node_modules\webdriver\build\utils.js:34:15)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at Function.newSession (C:\Users\User\IdeaProjects\lennuk-ui\node_modules\webdriverio\node_modules\webdriver\build\index.js:35:45)
    at Object.exports.remote (C:\Users\User\IdeaProjects\lennuk-ui\node_modules\webdriverio\build\index.js:53:22)
    at Runner._startSession (C:\Users\User\IdeaProjects\lennuk-ui\node_modules\@wdio\runner\build\index.js:123:56)
    at Runner._initSession (C:\Users\User\IdeaProjects\lennuk-ui\node_modules\@wdio\runner\build\index.js:103:25)
    at Runner.run (C:\Users\User\IdeaProjects\lennuk-ui\node_modules\@wdio\runner\build\index.js:52:19)
DEBUG @wdio/local-runner: Runner 0-0 finished with exit code 1
FAILED in T:/SSLLennuk/DXE/Lennuk-Shortcut.lnk - C:\Users\User\IdeaProjects\lennuk-ui\test\lennuk.spec.ts

when synergy of arguments "appWorkingDir" & "app" are used for launching application via its shortcut. For instance:

{
 appWorkingDir: 'T:/Delphi/',
 app: 'T:/Delphi/Lennuk-Shortcut.lnk'
}

Launching the test with only property "app" is fine for shortcuts. However, the app uses a certificate, what it searches for in app's directory. That's why I need property "appWorkingDir" to work with shortcuts too (it's fine with app: '*.exe').

Immediate answer regarding *.exe: Path to direct .exe fail I cannot use, because its name changes constantly. The second reason is that specific flag = "appArguments" is specified in shortcut. There is no flag for the application to specify a path to the necessary certificate.

Any help/solution?

mykola-mokhnach commented 2 years ago

Please provide the full server log

Alek5andr commented 2 years ago

Please provide the full server log

appium-server-logs.txt Here you go! If you know exactly what to look for, please share. I could not figure out useful info.

mykola-mokhnach commented 2 years ago

[debug] [WinAppDriver] {"desiredCapabilities":{"platformName":"windows","ms:experimental-webdriver":true,"ms:waitForAppLaunch":21,"deviceName":"WindowsPC","appWorkingDir":"T:/Delphi/","app":"T:/Delphi/Lennuk-Shortcut.lnk"}}[info] [WD Proxy] Got response with status 500: {"status":13,"value":{"error":"unknown error","message":"The specified executable is not a valid application for this OS platform."}} [debug] [W3C] Matched W3C error code 'unknown error' to UnknownError [warn] [WinAppDriver] Could not start WinAppDriver session error = 'An unknown server-side error occurred while processing the command. Original error: The specified executable is not a valid application for this OS platform.', attempt = '1' from 'undefined' [debug] [WinAppDriver] HTTP/1.1 500 Internal Error

I'd say WAD does not support providing aliases as app. It must be an executable or an UWP app name.

Alek5andr commented 2 years ago

I'd say WAD does not support providing aliases as app. It must be an executable or an UWP app name.

Damn! In my situation shortcut is located on network drive, directing to last Delphi application version. It's impossible to predict, what version was released last (no info how dost shortcut compilates either).

Close the thread, if no more suggestions.

mykola-mokhnach commented 2 years ago

Isn't it possible to figure out what app path the alias is pointing to from the client code before creating the session? Something like https://stackoverflow.com/questions/39309779/how-to-get-full-target-string-from-shortcut-lnk

Alek5andr commented 2 years ago

Isn't it possible to figure out what app path the alias is pointing to from the client code before creating the session?

As for a possible solution, I have implemented shortcut's target field's value grabber using command line tools:

import { execSync } from 'child_process';
execSync(`type ${filePath} | find "${searchValue}"`).toString();

where "type" - displays the contents of a text file, "find" - searches for a string of text in a file or files.

After grabbing I provide "app" property with a necessary app's version of exe-file.