Create session and get screenshot error if start WinAppDriver by Windows Service
Start WinAppDriver
- Add path of WinAppDriver to PC environment
- Register WinAppDriver as a service of Windows by this command: sc create WinAppDriver binPath= "cmd.exe /c start WinAppDriver.exe 4725/wd/hub" start= auto
- Start WinAppDriver service

Use WinAppDriver by REST API
Scenario 1: Create root session
Meet error when get screenshot

Scenario 2: Create WinApp session

What are you trying to achieve?
- Our team build a mobile test infrastructure to support UI automation test triggered by Azure DevOps Pipeline.
- Our main process was registered as a Windows service because we want to make sure it can be restarted after restarting Windows.
- The infrastructure use Appium to support Android, iOS··· And the process of Appium will be started by the main process.
- Recently, we are going to support a testing scenario that operate Windows App and Android App at the same time. When we try to run it, the error happened.
- We tried to modify the Log On property of Windows Service, but it didn't work.
if you are using azure pipeline there is a task to start and stop winappdriver. Also appium supports windows automation using winappdriver under the hood.
Windows services run in session 0, which is non-interactive/headless. This means that you cannot do any UI/visual interactions, because there is nothing to interact with. Out of interest, why do you want to run it as a service?
Windows services run in session 0, which is non-interactive/headless. This means that you cannot do any UI/visual interactions, because there is nothing to interact with. Out of interest, why do you want to run it as a service?
Thanks for your comment. We build a mobile test infrastructure, and the architecture of the infrastructure is 1 center -> n agents. The agents are used to run test cases. We want to register the main process of agents as a Windows service to make sure it can be started automatically after PC rebooting caused by system update or other reason.
if you are using azure pipeline there is a task to start and stop winappdriver. Also appium supports windows automation using winappdriver under the hood.
We want to decouple the test infrastructure with ADO and the ADO will not connect with our agents directly. The ADO can trigger a test task in test center by Gradle plugin or ADO extension. Then, the center distributes task to targeted agents.
2. WinAppDriver
BTW, the WinAppDriver will started by the main process of agents, so it will be a child process of Windows service
By agent do you mean an Azure pipelines agent? AFAIK the agent service can instead also be run (and should be if you want to do UI automation) as an interactive process (i.e. headful).
If this is not possible or not what you want, you can simply let the agent configure a startup script which automatically starts WinAppDriver.