سؤال

can't run the automated project in testcomplete when calls from jenkins.

In our continuous integration part ,the project is automated using testcomplete and it is calling through jenkins with the help of bat file.The scripts inside the bat file is

"C:\Program Files\Automated QA\TestComplete 7\Bin\TestComplete.exe "  "D:\Test Complete7 Projects\ProjectInput_AllSamples\ProjecInputs.pjs" /r /p:Samples /rt:Main "iexplore" /e

It will open testcomplete and iexplorer ,but it is not filling the data(automation). It is working perfectly when we directly call the bat file with out jenkins.Is there any solution

هل كانت مفيدة؟

المحلول

From your description it sounds like something in Windows stopping you from allowing your test application to work normally. It might be the fact that the second user could be a problem but I can't confirm that as I was not able find any definite explanations of how it works in Windows XP. I am pretty sure that this won't work on a Windows Vista, 7, 8 or server machine though because of the changes in architecture.

It sounds like the best solution is to make sure that your automated UI tests are started by an interactive user. When I was trying to add automated testing to our builds we used TestComplete 7 on a Windows XP SP2 virtual machine. In order to start our tests as an interactive user we:

  • Made an user log on when windows started, this way there was always an interactive user which means there was an actual desktop session which has access to the keyboard / mouse. I seem to remember (but can't find any links at the moment) that without an interactive user there is no active desktop that can access the keyboard / mouse.
  • We wrote a little app that would start when the interactive user logged on. This app would look at a specific file and when that file changed / was created it would read the file and start the application. The code for this app looked somewhat like this:

    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Globalization;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    
    namespace ApplicationStarter
    {
        class Program
        {
            // The string used to indicate that the application should quit.
            private const string ExitString = "exit";
    
            // The path which is being watched for changes.
            private static string s_LoadFilePath;
    
            static void Main(string[] args)
            {
                try
                {
                    {
                        Debug.Assert(
                            args != null, 
                            "The arguments array should not be null.");
                        Debug.Assert(
                            args.Length == 1, 
                            "There should only be one argument.");
                    }
    
                    s_LoadFilePath = args[0];
                    {
                        Console.WriteLine(
                            string.Format(
                                CultureInfo.InvariantCulture, 
                                "Watching: {0}", 
                                s_LoadFilePath));
                    }
    
                    if (File.Exists(s_LoadFilePath))
                    {
                        RunApplication(s_LoadFilePath);
                    }
    
                    using (var watcher = new FileSystemWatcher())
                    {
                        watcher.IncludeSubdirectories = false;
                        watcher.NotifyFilter =
                           NotifyFilters.LastAccess 
                           | NotifyFilters.LastWrite 
                           | NotifyFilters.FileName 
                           | NotifyFilters.DirectoryName;
                        watcher.Path = Path.GetDirectoryName(s_LoadFilePath);
                        watcher.Filter = Path.GetFileName(s_LoadFilePath);
    
                        try
                        {
                            watcher.Created += OnConfigFileCreate;
                            watcher.EnableRaisingEvents = true;
    
                            // Now just sit here and wait until hell freezes over
                            // or until the user tells us that it has
                            string line = string.Empty;
                            while (!string.Equals(line, ExitString, StringComparison.OrdinalIgnoreCase))
                            {
                                line = Console.ReadLine();
                            }
                        }
                        finally
                        {
                            watcher.Created -= OnConfigFileCreate;
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
    
            private static void RunApplication(string configFilePath)
            {
                var appPath = string.Empty;
                var arguments = string.Empty;
                using (var reader = new StreamReader(configFilePath, Encoding.UTF8))
                {
                    appPath = reader.ReadLine();
                    arguments = reader.ReadLine();
                }
    
                // Run the application
                StartProcess(appPath, arguments);
            }
    
            private static void StartProcess(string path, string arguments)
            {
                var startInfo = new ProcessStartInfo();
                {
                    startInfo.FileName = path;
                    startInfo.Arguments = arguments;
                    startInfo.ErrorDialog = false;
                    startInfo.UseShellExecute = true;
                    startInfo.RedirectStandardOutput = false;
                    startInfo.RedirectStandardError = false;
                }
    
                Console.WriteLine(
                    string.Format(
                        CultureInfo.InvariantCulture, 
                        "{0} Starting process {1}", 
                        DateTime.Now, 
                        path));
    
                using (var exec = new Process())
                {
                    exec.StartInfo = startInfo;
                    exec.Start();
                }
            }
    
            private static void OnConfigFileCreate(
                object sender, 
                FileSystemEventArgs e)
            {
                Console.WriteLine(
                   string.Format(
                      CultureInfo.InvariantCulture,
                      "{0} File change event ({1}) for: {2}",
                      DateTime.Now,
                      e.ChangeType,
                      e.FullPath));
    
                // See that the file is there. If so then start the app
                if (File.Exists(e.FullPath) &&
                   string.Equals(s_LoadFilePath, e.FullPath, StringComparison.OrdinalIgnoreCase))
                {
                    // Wait for a bit so that the file is no 
                    // longer locked by other processes
                    Thread.Sleep(500);
    
                    // Now run the application
                    RunApplication(e.FullPath);
                }
            }
        }
    }
    

This app expects the file to have 2 lines, the first with the app you want to start and the second with the arguments, so in your case something like this:

C:\Program Files\Automated QA\TestComplete 7\Bin\TestComplete.exe
"D:\Test Complete7 Projects\ProjectInput_AllSamples\ProjecInputs.pjs" /r /p:Samples /rt:Main "iexplore" /e

You should be able to generate this file from Jenkins in a build step.

Finally you may need to watch the TestComplete process for exit so that you can grab the results at the end but I'll leave that as an exercise to reader.

نصائح أخرى

If you are running Jenkins (either master or slave) as a windows service, ensure it is running as a user and not as Local System.

We also do the same as Gentlesea's recommends, we run TestExecute on our Jenkins Slaves and keepo the TestComplete licenses for the people designing the TestComplete scripts.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top