将Selenium测试引导到网格上的各种平台并不';不行?

将Selenium测试引导到网格上的各种平台并不';不行?,selenium,grid,Selenium,Grid,Selenium 2.38.0、Grid2、Java 1.7、TestNG框架、Firefox 27.0、Chrome 33.0、Windows 7、Windows 8 摘要-我在实验室的5个虚拟机共享上安装了Selenium Grid2,节点如下: 集线器-Win7 节点1-Win7/Firefox 节点2-Win7/Chrome 节点3-Win8/Firefox 节点4-Win8/Chrome 问题是,我将平台作为XML参数与TestNG一起传递,以在Selenium驱动程序启动时设置平台名

Selenium 2.38.0、Grid2、Java 1.7、TestNG框架、Firefox 27.0、Chrome 33.0、Windows 7、Windows 8

  • 摘要-我在实验室的5个虚拟机共享上安装了Selenium Grid2,节点如下:
  • 集线器-Win7 节点1-Win7/Firefox 节点2-Win7/Chrome 节点3-Win8/Firefox 节点4-Win8/Chrome

  • 问题是,我将平台作为XML参数与TestNG一起传递,以在Selenium驱动程序启动时设置平台名称和平台功能,以便集线器将其定向到正确的节点。这似乎不起作用,测试似乎总是在第一个节点(仅限Win7/Firefox)上启动。以下是我为Firefox设置的驱动程序代码,作为示例:

     public void setDriver(String browser,String environment,String platform) throws MalformedURLException, IOException {      
     switch (browser) {
     case "firefox":
     FirefoxProfile ffProfile = new FirefoxProfile();
     ffProfile = new ProfilesIni().getProfile(Constants.FF_PROFILE_PATH);
    
     caps =  DesiredCapabilities.firefox();
     caps.setCapability(FirefoxDriver.PROFILE,ffProfile); // RemoteWebDriver must use DesiredCapabilities, WebDriver can use same or Options...
    
     // this directs what remote grid node to run on...
     if ( environment.equalsIgnoreCase("remote") ) {
        switch(platform) {
        case "Window 7":
           caps.setCapability("platform","WINDOWS");
           caps.setCapability("platformName","WIN7-firefox");
           break;
        case "Window 8":
           caps.setCapability("platform","WIN8");
           caps.setCapability("platformName","WIN8-firefox");
           break;
        default:
           break;
        }
    
        this.driver = new RemoteWebDriver(new URL(Constants.REMOTE_HUB_URL),caps);
     }
    
     else
        this.driver = new FirefoxDriver(caps);
    
     break;
    
  • 如果我将XML参数更改为“Windows 8”,有时它会在Windows 7节点上启动,有时如果其他节点忙,它会在Windows 8节点上启动。任何人都知道这不起作用的原因,我通过JSON配置文件对节点进行了如下配置:

  • 节点1:

    {
       "capabilities":
       [
          {
             "platformName": "WIN7-firefox",
             "browserName": "firefox",
             "browser-version": "",
             "maxInstances": 1,
             "platform": "WINDOWS",
             "seleniumProtocol": "WebDriver",
             "acceptSslCerts": true,
             "javascriptEnabled": true,
             "takesScreenshot": true
          }
       ],
    
    节点2:

    "capabilities":
       [
          {
             "platformName": "WIN8-firefox",
             "browserName": "firefox",
             "browser-version": "",
             "maxInstances": 1,
             "platform": "WIN8",
             "seleniumProtocol": "WebDriver",
             "acceptSslCerts": true,
             "javascriptEnabled": true,
             "takesScreenshot": true
          }
       ],
    

    这是因为win7节点使用平台“WINDOWS”,这意味着它可以接受任何WINDOWS执行请求,包括WINDOWS 8

    虽然看起来不太好,但您可以使用“VISTA”而不是“WINDOWS”来分隔这两个平台组。我想知道他们为什么不添加“WIN7”选项或自定义条件


    显然,平台名在这里不起作用

    我想在Linux平台上执行?我可以知道我需要说明什么吗?