Forum Discussion

Pramod94's avatar
Pramod94
New Contributor
2 years ago

Running TestComplete tests in VM when disconnected

Hi,

I am trying to Run the TestComplete test in a self-hosted interactive mode windows 2019 server VM.

 

Issue: Getting "Sessionname Disc not found" error when a batch is ran.

 

Steps I followed to run Tests:

1. I have a VM which is created in an Interactive mode and TestComplete is installed in that with floating user license.
2. I have linked the Testcomplete tests with Microsoft TestPlan.
3. I have created a release pipeline as shown below in the screenshot.
4. I have created a "Disconnect.bat" file with the below script and saved it in the project folder itself.
 
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
  %windir%\System32\tscon.exe %%s /dest:console
)
 
5. I have a task called "Batch Script" in my deployment group job where I have given the path to the script from TFS.
6. when I ran the tests using TestPlan script ran with below logs

7. and when see the next log of VsTest it failed

8. Finally when I check the test log why it failed, then it showed as "Unable to navigate to the https://webpage url'

9. NOTE: same test works fine when i run it in the testcomplete tool or logged into VM and run.

7 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Create your batch file to run your TC project on the VM. Run it, and make sure it works. Then create a scheduled task to call the batch file on your VM. Run the scheduled task, and make sure it works.

     

    On the VM, call tscon. This will disconnect you from the VM, but your session will remain active. From another computer, connect to your VMs Task Schedular, and run the the schedule task, make sure it works.

     

    If you connect to your VM, Task Manager will show two active sessions. Your current session and the pervious session. 

     

    Try and undersand how the above works, and you should then be able to configure your job.

     

    If you run the following, you'll see the output it generates. And, tscon is expecting either session id or name as a parameter

    for /f "skip=1 tokens=3" %s in ('query user %USERNAME%') do (echo %s)
    
    or
    
    query user %USERNAME%

     

     

     

    • MatthewB's avatar
      MatthewB
      Occasional Contributor

      What is tscon ?  I am running into the same issue.  I have the batch file to run the testExecute file and can run task scheduler over night to run the Execution plan.  The only issue is that I have to run the VM overnight as an active window on the laptop.  I would like to disconnect the program from needing an active connection to the VM.  Is that possible?

  • Pramod94's avatar
    Pramod94
    New Contributor

    Hi rraghvani

    Thanks for this suggestion.

    Yeah this will work somehow but what if I want to run only few selected tests from TestPlan, then will this work ?

     

    One more question -

    keeping the VM always open on a console session reduce the system security ?

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I suggest you create a small TC project with a few tests and execution plans, and get this to work on your VM, with the information I have provided. 

     

    Once you get the above working, you can then refer to TestComplete Command Line and SessionCreator

     

    I have no issues with keeping my VM opened, as only a few testers have access to it, and it can not be accessed from outside the corporation

  • Pramod94's avatar
    Pramod94
    New Contributor

    Hi,

    Thanks for the suggestion and quick response.

     

    I will try out those and come back

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    It's quite difficult for me to explain without being technical. It’s the approach I took, breaking things down into smaller sections to understand how TC works. Test these small sections, to ensure they work, and then eventually bringing these sections together.