Is it possible to run Coded UI tests without having to connect via remote desktop?
Asked Answered
E

8

18

I'm attempting to automate Coded UI tests.

My test controller launches the tests on a remote test server, which I normally access via a Remote Desktop connection.

Is it possible to run the Coded UI tests without having to connect via remote desktop?

Currently, the tests only run when I have connected via Remote Desktop, and the window must be open. When I close the Remote Desktop session, the tests do not run.

If it isn't possible to run coded UI tests without remote desktop, how can I automate connecting via remote desktop?

Thanks

Enrage answered 31/7, 2012 at 16:12 Comment(4)
what language what framework?Spine
C# .NET 4.0, Visual Studio 2010 SP1 FP2, Windows 7.Enrage
why do you want an interactive test ? can you not just write unit tests for the widget interfaces ?Spine
I have been asked to create automated UI sanity tests, so that is what I am hoping to do. I am specifically testing the interface, so why would I write unit tests? We already have unit tests.Enrage
E
4

The easiest solution to this problem was simply to enable auto-logon on my test environment (there are a variety of ways of doing this depending on OS).

With auto-logon enabled, when I restart the test environment (using the 'shutdown.exe /r' command, which can be scripted), the test environment loads back up with an active, logged on session, and so the tests can run successfully.

For my nightly test automation, I enabled auto-logon on my test environment and scheduled a restart prior to test execution.

I have had no issues with this method - and it means I don't have to connect via Remote Desktop.

Enrage answered 13/9, 2012 at 9:52 Comment(0)
H
18

I ran into the same issue with our remote test machine, but our test machines run on Hyper-V. With Hyper-V, the solution is simply to connect via Hyper-V instead of Remote Desktop Connection, and closing the Hyper-V connection won't lock the computer.

Another suggestion would be to get around the fact that Remote Desktop automatically locks your screen. There's a quick bit about that here: http://homeservershow.com/remote-desktop-session-locks-workstation-after-exit.html

Basically, run "tscon.exe RDP-Tcp#0 /dest:console" in command prompt from the remote machine when you want to disconnect. The machine should remain unlocked and the tests will run just fine.

According to @Zatricion, that command can be generalized:

tscon.exe %sessionname% /dest:console
Harper answered 1/8, 2012 at 14:21 Comment(5)
Yeah, unfortunately the business where I am working do not use Hyper-V. All the machines are physical machines.Enrage
Added another suggestion to my answer. Check it out. I researched this myself, but actually I find this something quite useful I'll use for myself!Harper
Great, thanks, I'll have to give this a try! If it does work, do I have to run this command each time I go to disconnect from Remote Desktop?Enrage
Yes unfortunately, however, my suggestion, as well as the suggestion on the linked page is to create a desktop shortcut and set that command as its target. That way to exit you just click a desktop shortcut!Harper
tscon.exe %sessionname% /dest:console worked better for me since the number kept incrementingCytogenetics
E
4

The easiest solution to this problem was simply to enable auto-logon on my test environment (there are a variety of ways of doing this depending on OS).

With auto-logon enabled, when I restart the test environment (using the 'shutdown.exe /r' command, which can be scripted), the test environment loads back up with an active, logged on session, and so the tests can run successfully.

For my nightly test automation, I enabled auto-logon on my test environment and scheduled a restart prior to test execution.

I have had no issues with this method - and it means I don't have to connect via Remote Desktop.

Enrage answered 13/9, 2012 at 9:52 Comment(0)
S
3

From MSDN:

The computer that is running an agent on which you want to run coded UI tests cannot be locked or have an active screen saver.

If you are running your CodedUi Tests through Visual Studio (means that tests are executed under your account), I believe that you must be connected via remote desktop to the remote test server.

However, you can use Microsoft Test Manager to run your tests:

  1. Create a virtual environment.
  2. Setup your virtual machines so they can run automated tests.
  3. Install the Test Controller and Test Agent.
    -Set up the Test Agent to run as Interactive Proccess so it can run CodedUi Tests.
    -Set up the Test Controller to run with Microsoft Test Manager.
  4. Create a Test Plan through MTM and run tour tests in your virtual environment. There is no need to be connected in the remote server now, because your tests will run under the account that runs the Test Agent (note: you should create one for testing purposes).
Swartz answered 1/8, 2012 at 14:11 Comment(9)
Thanks. For now, I have been attempting to automate the tests by automatically launching Remote Desktop from the test controller machine to run the tests, but I'm not sure if this is possible if I don't have an active connection to the test controller via Remote Desktop.Enrage
If it is the Remote Desktop window that bothers you, you can just close it. Your LogIn session will not close and I think that you will be able to run your tests. You can try it.Swartz
With Microsoft Test Manager, is it possible to schedule daily automated tests? In MTM, I only see the option to manually start automated test runs.Enrage
You can run your tests or test cases or test plans from command line using Tcm. So, you could create a small servive or batch file that executes that command every day.Swartz
Although when I disconnect from RemoteDesktop, although the log-in session does not close, it still disconnects, and so there is no active session for the tests to run on. Is there any way around this?Enrage
Also, I don't think it is true that you don't need to be connected via Remote Desktop if the tests are run via Microsoft Test Manager. Any time I run tests via MTM, I get the exact same error message: "Automation engine is unable to playback the test because it is not able to interact with the desktop". Again, the tests will only run via Remote Desktop.Enrage
My suggestion was to run your tests via MTM using a new account for testing purposes. This account should be, of course, logged in the vm. This account can be logged in as many virtual machines as you want. You can manage this via the Lab Center of MTM.Swartz
Oh okay, I may consider creating a virtual environment for this then. I managed to get it working without Remote Desktop, though. I enabled auto-logon on the machine, and scheduled the machine to restart. When it starts back up again, it logs in to an active session, so the tests are able to run.Enrage
disconnect from Remote Desktop using the commandline: serverfault.com/questions/205902/… it keeps the session alive.Ecto
P
2

this is very easy please check this blog post here this thing is explained in very simple way How to schedule Microsoft coaded UI test execution when you don’t have MS TFS

  1. Create a release of stable coded UI project by following steps i. Open Build > Batch build

ii. Click rebuild if a release was already built

  1. After successfully building coded UI project navigate to release folder of project and copy testAutomated.dll named with your project name

  2. Place this dll on remote machine where you want to schedule your test execution

  3. Place .dll in some directory of remote machine e.g I am placing in D:\coadedUitest

  4. Install Miscosoft Test agent from this link on this machine where you want to execute test . http://www.microsoft.com/en-us/download/details.aspx?id=38186

  5. After installing test agent verify MS test is present in location

  6. Open note pad and enter following text D: cd coadedUitest set mstestPath="C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE" %mstestpath%\mstest /testcontainer:testAutomated.dll

  7. Save it with .bat extension

  8. Open .bat file by double clicking it to verify tests are executed or not

  9. After successful execution open windows task scheduler and create a scheduled task to run this created .bat file.

http://testingtoolstecniques.blogspot.com/2014/11/how-to-schedule-microsoft-coaded-ui.html

Psychrometer answered 19/11, 2014 at 9:21 Comment(1)
Link only answers! Please add details in your post.Stereobate
S
1

UPDATE:

Using the VSO or TFS2015 build system no longer need a remote connection for the tests to run. Create a build or a release running the task "Visual Studio Test Agent Deployment", then run the "Run Functional Tests" Task.

The best approach would probably be, create a build that drops your build artifacts, then create a release that deploys the site from the artifacts and runs the Coded UI Tests against that site.

NOTES:

  • If you start a remote connection manually the run will fail.
  • If you create a remote connection and disconnect instead of logging out the run will fail.
  • Auto login enabled and a restart will still allow these tests to run.
  • Using Hyper-V you can see the desktop of the server running the tests, it is a very small window but gives you an idea of what the server is doing.
Suitor answered 10/8, 2016 at 14:5 Comment(0)
E
0

View/interact with the machine using VNC (for example, TightVNC )

Escrow answered 30/4, 2013 at 15:8 Comment(0)
C
0

You can use VMware to run your coded ui tests. if you minimize the VM , test will still continue.

See this link for more details. http://www.binaryclips.com/2016/03/coded-ui-tests-executing-test-case.html

Cultism answered 28/2, 2014 at 13:33 Comment(0)
D
-1

--Preferred Solution 1: Have a Hyper-V Client and simply run coded UI tests using a schedule task. No issues at all.

--preferred Solution 2: You need to have 2 VM. First remote desktop to VM 1, then from VM 1 remote desktop to VM 2 where Coded UI will be running. Once Coded UI started in VM2, simply disconnect VM 1. This will keep the session opened and will never have any issues

-less preferred Solution 3: Restart VM using command line. Make sue auto-log in is enabled on your VM. Have a scheduled task to run coded UI.

I used this method and found some of my tests breaks.

--least preferred Solution 4: use tscon.exe %sessionname% /dest:console I used this method but cannot guarantee that your test will run with out any issues

Drubbing answered 25/11, 2016 at 18:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.