Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.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
如何在多台远程机器上并行运行Selenium Webdriver C#测试?_C#_Nunit_Selenium Webdriver_Remotewebdriver - Fatal编程技术网

如何在多台远程机器上并行运行Selenium Webdriver C#测试?

如何在多台远程机器上并行运行Selenium Webdriver C#测试?,c#,nunit,selenium-webdriver,remotewebdriver,C#,Nunit,Selenium Webdriver,Remotewebdriver,我目前正在使用SeleniumWebDriver,并使用C#在Visual Studio 2012中开发测试。我已使用以下代码成功执行了远程测试: public static void Test_RemoteWebDriver() { string url = "http://11.11.11.11:4444/wd/hub"; DesiredCapabilities ieCapibility = DesiredCapabilities.Intern

我目前正在使用SeleniumWebDriver,并使用C#在Visual Studio 2012中开发测试。我已使用以下代码成功执行了远程测试:

public static void Test_RemoteWebDriver()
       {
        string url = "http://11.11.11.11:4444/wd/hub";

        DesiredCapabilities ieCapibility = DesiredCapabilities.InternetExplorer();
        ieCapibility.SetCapability("ignoreProtectedModeSettings", true);
        IWebDriver driver = new RemoteWebDriver(new Uri(url), ieCapibility);
        driver.Navigate().GoToUrl("http://www.google.com/");           
        driver.Quit();
       }
我现在想做的是使用一台机器作为自动化控制器,并在多台远程机器上执行测试。为了澄清,我希望在我的控制器机器上有Selenium代码,但能够在多台远程机器上运行测试。我该怎么做? 我也在使用NUnit运行测试,但我知道这可能不是并行测试的最佳解决方案。运行远程Selenium测试的最佳框架是什么? 非常感谢您的帮助,
John

我所做的(我不确定这是否是最好的方法)是在appsettings部分的app.config中为我要测试的每台服务器添加一个条目,如下所示:

 <!-- Server URLs to test  -->    
<add key="ApplicationUrl_DEV" value="http://localhost:44404"/>
<add key="ApplicationUrl_TEST" value="http://testserver:44404"/> 
类中的每个测试方法将执行N次,每个“TestFixture”属性执行一次。 在此之后,必须重载类构造函数:

protected Executer(string urlKey, string environment)
{
     BaseUrl = ConfigurationManager.AppSettings[urlKey];
     Environment = environment;
}
在此场景中,urlKey是当前TestAttribute的第一个值,environment是第二个值。 这样,我就得到了当前服务器的URL,并将其用作我的基本URL:

BaseUrl = ConfigurationManager.AppSettings[urlKey];
Environment = environment;

以及用于日志记录的“环境”。

已经有一段时间了,下面是我最后要做的。我最终使用NUnit来运行测试。现在,我的自动化将NUnit和Selenium文件复制到远程机器,在那里运行自动化,并将结果文件复制回控制器机器。很适合我的需要。
John

我真的不明白这与同时在多台机器上运行自动化有什么关系…@evanmcdonnal这种方式允许多次运行相同的测试,提供您可以利用的参数。如果将这些参数中的任何一个设置为URL,则可以同时在多个服务器上运行测试。您确定这不意味着您可以同时在多个服务器上运行测试吗?我想问题是如何在多台服务器上并行运行自动化,而不是如何在不同的环境下运行自动化(即QA、Dev、staging和prod)。谢谢你的建议。我已经澄清了我的问题。我真的在寻找像Selenium Grid这样的东西来运行这些测试,但我希望听到更好的解决方案,如果它们存在的话。你知道你要完成的是一项巨大的开发任务,实现库提供的一些简单功能你将一无所获。我已经澄清了我的问题,如果我含糊其辞,我道歉。我确信这在使用网格之类的东西之前就已经做过了,但我希望专家们能告诉我最好的方法是什么。在我以前的工作中,我们的自动化系统能够做到这一点,但实现这一点的代码是一个定制的调度器,负责启动各种任务。我不认为有任何简单的方法来实现这个功能,我可能是错的,但总的来说,这不是一个简单的问题,我不认为你会找到一个简单的解决方案。
BaseUrl = ConfigurationManager.AppSettings[urlKey];
Environment = environment;