How to execute Coded UI Script from an external Java application? RRS feed

  • Question

  • Hi,

    I have a requirement to run a coded ui script from java application. The script opens a url in the browser, takes a username and a password, logs into the website and logs out. I need to send the  username and password parameters from the java application to the script and feed the status of the script execution back to the java application.

    I tried to do something like this.

    (a) Recorded and created the script using Visual Studio UI Test Builder.

    (b) Removed the hardcoded username and password values from the script (both in .cs and xml files)

    (c) Referred the script as a library (dll) in another C# console based application (consoleapp.exe)

    (d) From the consoleapp, I am able to access the public properties like username, password etc of the script and providing arguments.

                    Playback.PlaybackError += Playback_PlaybackError;
                    CUITRec.CodedUITest1 obj = new CUITRec.CodedUITest1();
                    //obj.UIMap.LoginRecordedMethodParams.UIPleaseenteryourneEditText = "username123";
                    obj.UIMap.LoginRecordedMethodParams.UIPleaseenteryourneEditText = args[0];
                    //obj.UIMap.LoginRecordedMethodParams.UIPleaseenteryourneEdit1Password = @"password123";
                    obj.UIMap.LoginRecordedMethodParams.UIPleaseenteryourneEdit1Password = args[1];

    (e) The above consoleapp.exe, I should run from a java application and send the necessary parameters.

    (f) For time being, instead Java application, I am just trying to execute the above consoleapp.exe from another external C# console app as a process and sending the necessary parameters (username & password) as arguments to the process. (My whole idea is to run the consoleapp.exe as a process from the Java application)

     class Program
            static void Main(string[] args)
                    ProcessStartInfo psi = new ProcessStartInfo(@"D:\nftest\ConsoleApp.exe");
                    psi.UseShellExecute = false;
                    psi.RedirectStandardError = true;
                    psi.RedirectStandardOutput = true;
                    psi.Arguments = @"username123 password123";
                    Process proc = Process.Start(psi);
                    string output = proc.StandardOutput.ReadToEnd();
                    Console.WriteLine("output: " + output);
                catch (Exception ex)

    I just want to know

    (a) if this is the correct/good approach or please let me know any better solutions for this kind of requirement.

    (b) Also how do I remove the dependency on the visual studio. (this approach works only if target machine contains visual studio)

    • Edited by ykbharat Tuesday, September 22, 2015 11:09 AM content edited
    Tuesday, September 22, 2015 11:03 AM


  • Hi,

    If it works fine, I think it’s ok.

    The parameters could be in a file.

    # Creating a Data-Driven Coded UI Test


    In my opinion, you may try to use the command line (MSTest, VSTest.Console) to run the test. (lunch command line from JAVA application)

    On the other hand, UI Automation require VS Ultimate or VS Premium. So, I think you need to install Visual Studio.



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, September 23, 2015 7:32 AM