microsoft / WinAppDriver

Windows Application Driver
MIT License
3.59k stars 1.39k forks source link

Azure Pipelines WinAppDriver not starting #1588

Open kevin306 opened 2 years ago

kevin306 commented 2 years ago

I'm unable to successfully run the driver in my azure dev ops env. Getting this error when trying to run my tests after enabling winappdriver task.

error: A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://127.0.0.1:4723/session. The status of the exception was UnknownError, and the message was: No connection could be made because the target machine actively refused it. No connection could be made because the target machine actively refused it

I am using a Microsoft hosted agent and yaml looks like:

- task: Windows Application Driver@0
    inputs:
      OperationType: 'Start'
      AgentResolution: '1080p'

  - task: VSTest@2
    displayName: 'UI Tests'
    inputs:
      testSelector: 'testAssemblies'
      testAssemblyVer2: '$(Build.SourcesDirectory)\**\**\*test.dll'
      searchFolder: '$(Build.SourcesDirectory)'
      platform: '$(platform)'
      configuration: '$(configuration)'
    continueOnError: true

  - task: Windows Application Driver@0
    inputs:
      OperationType: 'Stop'

My understanding is for Microsoft hosted agents it should work out of the box but output from winappdriver stop task says it never started. Unable to close WinAppDriver.exe due to process not found. WinAppDriver already not running?

I saw some people mentioning setting interactive mode on the agent but is this required for microsoft hosted ones?

anunay1 commented 2 years ago

Interactive mode should be ON for Microsoft hosted agents also.

kevin306 commented 2 years ago

You mean by default it should be on, or I need to enable this myself somehow?

anunay1 commented 2 years ago

check this

anunay1 commented 2 years ago

@kevin306 let me know if it works with the link that I provided.

kevin306 commented 2 years ago

@anunay1 But that is for a self hosted agent right. It seems like from log from winappdriver stop that the driver never started. Is it installed by default on microsoft hosted agents?

anunay1 commented 2 years ago

no you need to use the below task to install WinAppDriver https://marketplace.visualstudio.com/acquisition?itemName=WinAppDriver.winappdriver-pipelines-task

anunay1 commented 2 years ago

check this link

kevin306 commented 2 years ago

Yes so as I mentioned above I have that installed already and is in my yaml

- task: Windows Application Driver@0
    inputs:
      OperationType: 'Start'
      AgentResolution: '1080p'

  - task: VSTest@2
    displayName: 'UI Tests'
    inputs:
      testSelector: 'testAssemblies'
      testAssemblyVer2: '$(Build.SourcesDirectory)\**\**\*test.dll'
      searchFolder: '$(Build.SourcesDirectory)'
      platform: '$(platform)'
      configuration: '$(configuration)'
    continueOnError: true

  - task: Windows Application Driver@0
    inputs:
      OperationType: 'Stop'

And I am using windows-latest as image which I understand has everything setup already to run ui testing correct?

kevin306 commented 2 years ago

any updates on this?

Shakevg commented 2 years ago

@kevin306 What Hosted Agent specification are you using? It is working for me on Hosted Agent 2019, but for tasks configured via UI. Do you have the same issue if you configured the pipeline via UI (not yaml)?

kevin306 commented 2 years ago

@Shakevg I am using Microsoft Hosted windows-latest which seems to be alias for Windows Server 2019 with Visual Studio 2019. I am not sure what you mean by pipeline via UI?

anunay1 commented 2 years ago

@kevin306 what @Shakevg means is are you creating the pipeline using the classic method where in you can choose the task using UI or importing a yaml file..

kevin306 commented 2 years ago

@anunay1 You mean like this image

For the winappdriver I added using the UI but for others I have just edited the yaml and pushed my branch.

As you can see the driver appears to start in this task. image

But in the stop task it complains there is no such process. image

This leads me to believe it is stopping immediately.

kevin306 commented 2 years ago

Instead of using the task provided by azure, I ran a powershell command to start driver:

  - powershell: |
      start-process -NoNewWindow -FilePath 'C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe' -ArgumentList "4723" 
    displayName: 'WinApp Driver Start'
    workingDirectory: '$(Build.SourcesDirectory)'

and as I suspected it is exiting immediately image

anunay1 commented 2 years ago

Is the developer mode set to ON?

kevin306 commented 2 years ago

@anunay1 This is a microsoft hosted agent, so everything should be set up to run the driver automatically.

Shakevg commented 2 years ago

@kevin306 Per documentation WInAppDriver should be installed and works on Hosted Agent https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml Try post ticket to Microsoft, I suppose this is an issue with your agent.

HugoRomat commented 2 years ago

Any update on this? I am hitting the same issue...

amrmahmoud11 commented 2 years ago

Same issue here

anunay1 commented 2 years ago

Can you share the yaml pipeline?

amrmahmoud11 commented 2 years ago

Can you share the yaml pipeline?

Adding this in the yaml solved it for me pool: vmImage: 'windows-latest'