繁体   English   中英

硒网格混淆了浏览器之间的测试

[英]Selenium grid mixing up tests between browsers

可以说我必须在2个浏览器中打开google,在1st中搜索Test1,在2nd中搜索Test 2。 它打开2个浏览器,在一个浏览器中编写Test1Test2并通过测试。 我如何解决呢?

如果我在每个测试函数中都声明驱动程序,它会很好地工作,但是如果我以后想要使用RemoteWebDriver在不同的计算机上运行它,则无法完成此操作(因为它随后仅使用一个节点,而在其他节点上不执行任何操作)也使用非静态浏览器,但不确定如何使用它,也不确定是否可以解决问题?

命名空间ParallelGrid {

[TestFixture]
[Parallelizable]
public class ParallelGrid1
{

    [ThreadStatic]
    public static IWebDriver driver;
      [SetUp]
       public void Setup()
       {

          ChromeOptions options = new ChromeOptions();
         driver = new ChromeDriver();
          // driver = new RemoteWebDriver(new Uri("http://xxx.xxx.xx.xxx:4444/wd/hub"), options.ToCapabilities(), TimeSpan.FromSeconds(600));//hub id goes here

       }


    [Test]
    [Parallelizable]
    public void Test1()
    {

        driver.Navigate().GoToUrl("https://www.google.com");
        driver.FindElement(By.Name("q")).Click();
        driver.FindElement(By.Name("q")).SendKeys("Test");
    }


    [Test]
    [Parallelizable]          
        public void Test2()
        {

            driver.Navigate().GoToUrl("https://www.google.com");
            driver.FindElement(By.Name("q")).Click();
            driver.FindElement(By.Name("q")).SendKeys("Grid");

        }

    }
}

为了使并行化与NUnit和C#一起使用,您一次只能对Test类进行并行化。 因此,您每堂课必须进行一次测试。

https://github.com/nunit/nunit/issues/2252

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM