WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Having to manually start WinAppDriver before Azure Pipeline runs a test

Open jfclancey opened this issue 2 years ago • 10 comments

Hello,

      Currently before I run the Azure pipeline for my automated test of a Windows client I need to start WInAppDriver manually on the VM. We have tried using a scheduler and that has not work. Since we are trying to have the test run on a schedule having someone need to start WInAppDriver. 

    If I don't start WinAppDriver I get the error, "Unable to connect to the remote server --> System.Net.Sockets.SocketException: No Connection could be made because the target machine actively refused it.

  The first thing the code does is check to see if the port is open and if it is not open it tries to start WinAppDriver. The error comes from checking to see if the port is open.  When I run this code from the command line on the VM it runs without an issue.

Should I be focused on opening WinAppDriver on the server or trying to open it from the pipeline?

TIA, John

jfclancey avatar Aug 10 '22 15:08 jfclancey

Please follow the doc

anunay1 avatar Aug 10 '22 16:08 anunay1

I followed the steps but I'm still having an issue. I see the WinAppDriver task open but it is running in the background. When I run the pipeline after I start it manually it works. Do I need to force it to the foreground and if so how?

jfclancey avatar Aug 12 '22 12:08 jfclancey

I followed the steps but I'm still having an issue. I see the WinAppDriver task open but it is running in the background. When I run the pipeline after I start it manually it works. Do I need to force it to the foreground and if so how?

The task is running WinAppDriver in the background. Could you add a post here WinAppDriver logs from the second task when you stop WinAppDriver? Also, post the error that you got in youк test.

Shakevg avatar Aug 12 '22 15:08 Shakevg

The error I'm getting from my test is " System.InvalidOperationException : Failed to locate opened application window with appId "

Below is what I see in the pipeline when starting WinAppDriver, not sure if this is what you're looking for. I didn't see anything in the Eventviewer on the server. Setting display resolution on Agent to - 1080p Launching WinAppDriver with 127.0.0.1:4723 WinAppDriver launch successful. Finishing: WindowsApplicationDriver

jfclancey avatar Aug 12 '22 16:08 jfclancey

Does your application have splash screen?

anunay1 avatar Aug 12 '22 16:08 anunay1

Yes it does. Before the splash screen appears there is a popup which has the status of checking for a new version of the application.

jfclancey avatar Aug 12 '22 16:08 jfclancey

Then you need to create a root session and jump to the open window, which language binding are you using?

anunay1 avatar Aug 12 '22 16:08 anunay1

if C# see #1341 if python check #1646

anunay1 avatar Aug 12 '22 16:08 anunay1

I have sort of the same problem.

  • I have a self hosted build pipeline in Azure Devops in which I have a standard start and stop task for WinAppDriver enabling a graphical test.
  • When WinAppDriver is already running the test depending on it succeeds (on an empty screen).
  • When not, the starting does not succeed, and obviously the test fails.
  • In both cases there is some red text displayed in the startup window. But I was not able to read or catch the text.
  • The normal Azure log window does not show any problems.

This used to work for me. I hadn't used this for a while, so a lot may have changed.

Questions

  • Is there a way to read or catch the output from the starting step?
  • Anything that may need to change in my setup?
  • Bug?

a-einstein avatar Aug 25 '22 17:08 a-einstein

@a-einstein Could you provide a code example and error that you got from the test? Maybe the test cannot create the session during starting of the app.

Shakevg avatar Aug 26 '22 16:08 Shakevg

Same problem for me. Everything works when I starts WinAppDriver manually using RDP to remote machine.

With pipeline instruction:

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

is just not being started and UI tests crashed because of unable to connect error.

If I run WinAppDriver manually before running pipeline then my tests run successfully

Also interesting thing that my pipeline contains task with WinAppDriver Stop operation but this successfully closes my manually run WinAppDriver session

ghost avatar Dec 12 '22 15:12 ghost

Then you need to create a root session and jump to the open window, which language binding are you using?

@anunay1 Can it still be a splash screen issue if it works when I start WinAppDriver manually?

@Shakevg here is the error image

jfclancey avatar Feb 01 '23 14:02 jfclancey

Then you need to create a root session and jump to the open window, which language binding are you using?

@anunay1 Can it still be a splash screen issue if it works when I start WinAppDriver manually?

@Shakevg here is the error image

Are you starting the test agent in admin mode?

anunay1 avatar Feb 01 '23 15:02 anunay1

Same problem for me. Everything works when I starts WinAppDriver manually using RDP to remote machine.

With pipeline instruction:

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

is just not being started and UI tests crashed because of unable to connect error.

If I run WinAppDriver manually before running pipeline then my tests run successfully

Also interesting thing that my pipeline contains task with WinAppDriver Stop operation but this successfully closes my manually run WinAppDriver session

Are you starting the test agent in admin mode?

anunay1 avatar Feb 01 '23 15:02 anunay1

@anunay1 the account I'm using has admin access on the VM. Is there something I can check to confirm it is in admin mode?

jfclancey avatar Feb 01 '23 16:02 jfclancey

Have you not installed any test agent in your VM? When you start winappdriver.exe manually, do you start it as an admin?

anunay1 avatar Feb 01 '23 17:02 anunay1

@anunay1 yes when I run it manually I start it as an admin. When opening Winappdriver through the pipeline I see it running in the background and instances of my application opening in the background as well.

jfclancey avatar Feb 01 '23 17:02 jfclancey

Oh ok then it's not starting in admin mode? Also what is the log that you get the pipeline for the winappdriver task?

anunay1 avatar Feb 01 '23 17:02 anunay1

@anunay1 it says it is successful.

I have tried to put in a delay before it looks for the exe but that didn't solve anything. It's opening additional instances of the application because it can't find the ones open earlier.

image

jfclancey avatar Feb 01 '23 18:02 jfclancey

@anunay1 The code is looking for the Window and when I do a check for any windows being open and it turns out there are no Windows open. I believe this is because the processes are in the background.

My application keeps opening new instances of the application and I check for a Window and the code returns that there are no Windows open even though I can see the process in the Task Manager. The application we are testing has a menu selection screen after the drop down. Once you get past the menu selection screen then the application goes to the task bar.

jfclancey avatar Feb 02 '23 16:02 jfclancey

Will it be possible to have a teams call?

anunay1 avatar Feb 02 '23 16:02 anunay1

@anunay1 yes I can. I'm in the US EDT time zone. How can I get you my contact information.

jfclancey avatar Feb 02 '23 17:02 jfclancey

The contact info is there in the profile. You can schedule it around 8PM IST.

anunay1 avatar Feb 03 '23 10:02 anunay1

@anunay1 I sent you an email from my yahoo account.

jfclancey avatar Feb 06 '23 20:02 jfclancey

Did not receive any mail? Can you send to [email protected]

anunay1 avatar Feb 07 '23 07:02 anunay1