Quantcast
Channel: New board topics in SmartBear Community
Viewing all articles
Browse latest Browse all 20990

The operation cannot be performed, because the user session is disconnected.

$
0
0

Hi,

 

I have a GUI test suite which I need to run on a remote computer according to a schedule, and I came to a problem I seem to unable to circumvent.

 

To put it simple, the test suite performs GUI testing of a rich Windows client. The test package contains a VB script which launches TestExecute and supplies the various parameters required. I run this script on a test machine, accessed via Remote Desktop (that is, if the computer is named XY, the script is run on XY, accessed remotely, and launches TestExecute on XY). As part of this script, I have included a tscon.exe redirection so that the remote desktop window can be closed. I have created a scheduled task running this VB script regularly.

 

When I run the script directly, it properly closes the remote desktop connection, and completes the tests successfully. When run by the task scheduler, it fails at some point with the error The operation cannot be performed, because the user session is disconnected.

 

The relevant portion of my VB script ([...] indicates removed code]:

 

 

' Paramteres --------------------------------------------------------------------------------------
'	

Dim TCPath 		' Path to TestComplete.exe
Dim ProjectSuite	' Full path of the project suite to invoke
Dim LogFolder 		' Path to log folder
Dim IniConfPath 	' Path to the configuration ini file
Dim LetAlone 		' Set to True when test runs on remote desktop which you don't want to 
			' keep open
' Set parameter values
TCPath 		= [...]
ProjectSuite 	= [...]
LogFolder 	= [...]
IniConfPath 	= [...]
LetAlone 	= true

' Global variables --------------------------------------------------------------------------------
'
Dim fso			' For file system access
Dim sh			' Shell object for environment variables

Dim operationalLog	' Log file for Test Complete runtime / command line errors
Dim businessLog		' Test log in MHT format

Dim timestamp		' Timestamp of invocation
Dim sessionName		' Session name for remote desktop sessions


' Preparatory steps -------------------------------------------------------------------------------

silent = false
timestamp = Now()

Set fso = CreateObject("Scripting.FileSystemObject")	
Set sh = CreateObject("WScript.Shell")

[...]
		

' Check if we need to redirect session so that GUI tests can run even when 
' remote desktop session is terminated.
If LetAlone Then
	' Get session name
	sessionName = sh.ExpandEnvironmentStrings("%SESSIONNAME%")	
	
	' Redirect session

' Version 1: when run manually on the remote computer ' sh.Run "tscon.exe " & sessionName & " /dest:console"

' Version 2: when run by task scheduler sh.Run "tscon.exe 0 /dest:console" End If ' Compose command line for test execution Dim command command = [...] ' Launch test sh.Run command, bWaitOnReturn = False

 

When starting manually on the remote desktop, the code line

 

sh.Run "tscon.exe " & sessionName & " /dest:console"

is uncommented, and code line

sh.Run "tscon.exe 0 /dest:console"

is commented. It properly obtains the session name and redirects it to the console, the connection is closed, and the test completes successfully. However I found that task scheduler always creates a session with ID of zero, so for the production configuration, the first line is commented out, and the second is made effective. The script properly closes the connection when run by task scheduler, and it performs successfully one of the GUI tests. This test opens the tested application and measures startup time by waiting for a control on its main screen to appear.

 

The second test is more complex, and it includes steps of clicking a DevEx XtraBars ribbon. This is the point where it fails:

Aliases.Foo.Ribbon.ClickItem("Project|Create Project|New Project|DropDownButton|New Project");

Do you have any tips for a workaround? What other differences may there be between running under a "real" remote session and under the session 0 created or used by Task Scheduler? I cannot get the point why it succeeds under a named session, and why not under session 0.

 


Viewing all articles
Browse latest Browse all 20990

Trending Articles