Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用selenium从unitests运行web应用程序_C#_Selenium_Testing_Iis - Fatal编程技术网

C# 使用selenium从unitests运行web应用程序

C# 使用selenium从unitests运行web应用程序,c#,selenium,testing,iis,C#,Selenium,Testing,Iis,我正在使用selenium测试我的产品屏幕截图的基线 尝试在tfs 2013 build中运行自动测试,我在另一台机器上安装了该测试,但要首先运行测试,我需要从VS运行网站,以便iis将托管它,然后测试才能正确运行 我正在搜索一个用于运行web应用程序的C代码[这是默认网站的子网站]有人知道吗?我自己也找到了答案 使用此代码从注册表获取IIS路径,然后使用IIS运行站点应用程序 RegistryKey key = Registry.LocalMachine.OpenSubKey(

我正在使用selenium测试我的产品屏幕截图的基线 尝试在tfs 2013 build中运行自动测试,我在另一台机器上安装了该测试,但要首先运行测试,我需要从VS运行网站,以便iis将托管它,然后测试才能正确运行


我正在搜索一个用于运行web应用程序的C代码[这是默认网站的子网站]有人知道吗?

我自己也找到了答案 使用此代码从注册表获取IIS路径,然后使用IIS运行站点应用程序

        RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\IISExpress\\10.0");
        Object o = null;
        if (key != null)
        {
             o = key.GetValue("InstallPath");
        }
        Process cmd = new Process();

        cmd.StartInfo.FileName = "cmd.exe";
        cmd.StartInfo.RedirectStandardInput = true;
        cmd.StartInfo.UseShellExecute = false;

        cmd.Start();

        using (StreamWriter sw = cmd.StandardInput)
        {
            if (sw.BaseStream.CanWrite && o != null)
            {
                sw.WriteLine(@"cd {0}", o);
                sw.WriteLine(@"iisexpress /path:{0}\mysit /port:whateverport", GetRootDirectory(context));

            }
        }

我将把这些责任分开。让Jenkins或teamcity或任何用于构建和部署内容的工具在某处启动webapp,然后在部署完成后触发测试运行。如果您在本地运行这些,您可以创建一个简单的脚本(不在您的c#测试代码中)来将webapp部署到localhost并针对该脚本运行测试。