microsoft / WinAppDriver

Windows Application Driver
MIT License
3.7k stars 1.4k forks source link

What could cause WinAppDriver to exit immediately after start? #1991

Open aries-zhang opened 7 months ago

aries-zhang commented 7 months ago

While I am trying to set up WinAppDriver to run as a different user on a CI agent, with the following command: (see my use case here: https://github.com/microsoft/WinAppDriver/issues/1983)

Start-Process -WorkingDirectory "C:\Users\Public" -FilePath "C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe" -Credential $credential -PassThru

WinAppDriver seems to exit immediately after it starts:

Windows Application Driver listening for requests at: http://127.0.0.1:4723/

Press ENTER to exit.

Exiting...

To rule out any user account related issues on the CI agent, with the same command but for notepad.exe:

Start-Process -WorkingDirectory "C:\Users\Public" -FilePath "C:\Windows\system32\notepad.exe" -Credential $credential -PassThru

it does not exit the newly started notepad process.

I'm aware that the env on the CI agent could be complicated and there might be something forcing the WinAppDriver process to exit. While it is hard to imagine what that something could be, I'm wondering if anyone else has similar experience or knows in what circumstances WinAppDriver could print out "Existing..." and exits?

Also, is the actual code that build WinAppDriver.exe in this repo? I was trying to search "Existing..." but did not find any related code in this repo?

anunay1 commented 7 months ago

You need to use double slash in the path for winappdriver

aries-zhang commented 7 months ago

Thanks @anunay1 , double slash doesn't seem to be the cause of exiting. I managed to work it around by running another C# WinForm app which starts WinAppDriver once it starts. This way I can start the WinForm app as the non-admin user and then WinAppDriver inherits the runas user and does not exit, although I still didn't figure out why WinAppDriver exits immediately when it is directly started by Start-Process.

gakera commented 6 months ago

I'm having the same problem and this issue also seems to address this: https://github.com/microsoft/WinAppDriver/issues/588