Not able to open URL in LoadTestStarting event when running load test

Locked Not able to open URL in LoadTestStarting event when running load test

  • 8 august 2012 04:25
     
     

    Hi,

    I'm working in VSTS Load Testing. I am trying to open a webpage before starting the load test. Hence, I'm using LoadTestStarting even to trigger the webpage using System.Diagonistics.Process.Start(strURL);

    But it gives me this strange error.

    System.ComponentModel.Win32Exception (0x80004005): An error occurred in sending the command to the application
       at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
       at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)

    How do i proceed further? is there any other way to open a webapplication in LoadTestStarting event.

    Thanks in advance

Toate mesajele

  • 9 august 2012 09:29
     
     

    Hi checkoutsree,

    Thanks for your  post!

    I am moving this thread to forum because this question is more related with Load Test, there are more load test experts in that forum and your question will get a better response.

    Best Regards,


    Cathy Kong [MSFT]
    MSDN Community Support | Feedback to us

  • 9 august 2012 11:01
    Moderator
     
     

    Hi checkoutsree,

    Thank you for posting in the MSDN forum.

    I have tried to open a web page using the LoadTestStarting event before starting the load test, I used a simple URL, and it can succeed.

    You can check if there are something wrong with your code in load test plugin, and try a simple URL to check if the error will occur .

    The following is part of my code in the load test plugin:

    public void Initialize(LoadTest loadTest)  {

          m_loadTest = loadTest;

          m_loadTest.LoadTestStarting += new System.EventHandler(OnLoadTestStarting);

            }

        void OnLoadTestStarting(object sender, System.EventArgs e) {

           System.Diagnostics.Process.Start("http://www.baidu.com");

            }

    I hope this is helpful to you.

    Thanks,

    Amanda


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • 9 august 2012 12:13
     
      Are cod

    Amanda,

    I tried using a simple URL also (like the ones you have mentioned). I'm getting the same error. Please help me out in opening a IE and trigger an URL. Please see my code below:

    using System;
    using Microsoft.VisualStudio.TestTools.LoadTesting;
    using System.Diagnostics;
    using System.Windows.Forms;
    namespace Utilities.TestPlugins
    {
        public class FullCleanup : ILoadTestPlugin
        {
            private LoadTest loadTest;
            private string strURL;
            public void Initialize(LoadTest loadTest)
            {
                this.loadTest = loadTest;
                loadTest.LoadTestStarting += new EventHandler(LoadTestStarting);
                loadTest.LoadTestFinished += new EventHandler(LoadTestFinished);
            }
            private void LoadTestStarting(object sender, EventArgs e)
            {
                // execute cleanup
                if (loadTest.Context["PerformCleanupBeforeLoadTest"].ToString().ToUpper() == "TRUE")
                    DoFullCleanup();
            }
            private void LoadTestFinished(object sender, EventArgs e)
            {
                // execute cleanup
                if (loadTest.Context["PerformCleanupAfterLoadTest"].ToString().ToUpper() == "TRUE")
                    DoFullCleanup();
            }
            private void DoFullCleanup()
            {
                strURL = "http://localhost/Cleanup/FullCleanup.aspx?EnvironmentForLoadTest=" + loadTest.Context["EnvironmentForLoadTest"].ToString();
                //System.Diagnostics.Process.Start(strURL);                
                ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe", strURL);
                Process.Start(startInfo);
                System.Threading.Thread.Sleep(20000);
            }
        }
    }
    Please help.
  • 9 august 2012 15:41
     
     Răspuns

    If your just trying to call your FullCleanup.aspx page, do not launch IE to do that, you will have permissions problems and more using that approach as you are finding out. Instead programmatically call FullCleanup.aspx using HttpWebRequest.

    Do a quick bing search and you can find lots of samples: Here is one that I saw:

    http://www.csharp-station.com/HowTo/HttpWebFetch.aspx

    Hope that will help you out.

    -Robert


    http://blogs.msdn.com/rogeorge

    • Marcat ca răspuns de checkoutsree 13 august 2012 12:35
    •  
  • 10 august 2012 03:37
    Moderator
     
     

    Hi checkoutsree,

    According to your code, I tried a simple URL to run again, it still can succeed and don’t get the error.

    About your issue, you can try to do these to avoid some probable problems:

    1. Try to run devenv/ResetSettings(in command prompt) to eliminate the related potential settings problem.
    2. Try to run “devenv.exe/SafeMode”. This can eliminate the possibility that third party packages are causing problems.
    3. Try to creating a new project. Sometimes corrupted project settings can cause problems.
    4. Try to reboot the operating system to safe mode. This can help to isolate whether any other applications are interfering with your Visual Studio. Note that some features(like IIS) are not available under safe mode. Please check whether this can be applied or not.
    5. Turn off “Protected Mode” in Internet Explorer and then reboot your IE.

    Also, I advice that you can run your project on another computer with the same Visual Studio to check if the error will occur.

    In addition, can you provide detailed information about your FullCleanup.aspx? I don’t know how to design it in the page so that I can’t reproduce your issue better.

    Thank you for your understanding.

    Best regards,

    Amanda


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • 13 august 2012 12:35
     
     

    Robert,

    It was a helpful reply. I implemented the same and works well.

    Thanks.