2015-07-10 132 views
2

我有一个测试,我试图在多个浏览器(IE,Chrome和Firefox)中并行运行。用C#和硒网格并行测试

[SetUp] 
     public void TestInitialize() 
     { 
      //EnvironmentAccess.LoadEnvironment(); 

      // Create a new instance of the Firefox driver 
      //driver = new FirefoxDriver(); 

      DesiredCapabilities capabilities = new DesiredCapabilities(); 
      capabilities = DesiredCapabilities.Firefox(); 
      capabilities.SetCapability(CapabilityType.BrowserName, "firefox"); 

     capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows)); 

     driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capabilities); 
    } 


[Test] 
     public void SampleTest() 
     { 
      string url = "https://google.com"; 
      try 
      { 
       driver.Navigate().GoToUrl(url); 
      } 
//other test code 
} 

[TearDown] 
     public void TearDown() 
     { 
      driver.Quit(); 
      driver.Dispose(); 
     } 

我想不出如何让它跨多个浏览器运行。我已经看到它在java中完成,但我试图通过c#来完成。我读了关于gallio,但无法理解如何正确地将它集成到我的代码中。

回答

0

加利奥是用于启动执行遇到一个伟大的工具,但你可能想使用MbUnit的为您的测试框架硒一起去探索。当我们在工作中遇到这个问题时,我们发现NUnit在可靠地并行运行测试时(如果有的话)相当固执。

MBUnit可作为Nuget包使用,因此安装非常简单。从那里,你只需要根据需要在你的方法上重新使用你的注释。

我会规定MBUnit在这一点上几乎是一个死的项目,并且在很长一段时间内还没有看到积极的开发。有了这些说明,我们已经看到在我的团队中使用它取得了很大的成功。它性能稳定,性能良好,并行性好,易于使用。考虑到项目的状态,值得一些考虑,但我确实推荐它。

0

当您使用远程webdriver时,使用它的浏览器会根据所需的功能进行指定。 构建驱动程序时,您需要提供其他浏览器所需的功能。

您想要使用的浏览器也需要安装并注册为节点的功能。

https://code.google.com/p/selenium/wiki/DesiredCapabilities