在Selenium Grid中指定Windows版本(或特定计算机) [英] Specifying Windows Versions (or Specific Machines) in Selenium Grid

查看:93
本文介绍了在Selenium Grid中指定Windows版本(或特定计算机)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个Selenium Grid,以涵盖一个需要全面涵盖以下组合的测试矩阵:三个提供相同服务的服务器(Windows Server 2003、2008和2012)和十个客户端(XP版本) ,win7,win8和win8.1),将分别访问这三台服务器以执行几乎相同的测试.这三个服务器部分很可能与这个问题无关,但出于上下文考虑,我将其放入其中.我正在通过TestNG DataProvider配置要使用的服务器.

I'm setting up a Selenium Grid in order to cover a test matrix that needs to comprehensively cover the following combinations: Three servers (windows server 2003, 2008, and 2012) that provide identical services and ten clients (of flavors XP, win7, win8, and win8.1) that will be accessing each of the three servers to perform nearly identical tests. The three servers part is most likely irrelevant to this question, but I threw it in for context's sake. I'm configuring which servers to use via TestNG DataProviders.

问题在于,我不仅要测试不同浏览器和浏览器版本以及操作系统之间的交互,还要测试所有四个版本的Windows.

The catch is that I want to test the interactions not just between different browsers and browser versions and operating systems, but also all four versions of windows.

据我所知DesiredCapabilities类将仅允许我在XP,VISTA和WINDOWS枚举之间进行指定.我已经找到了这个问题,并且已经得到了 Selenium Grid:Capabilities and Platform.WINDOWS7?

From what I can tell the DesiredCapabilities class will only allow me to specify between between XP, VISTA, and WINDOWS enums. I have found this question and it has been answered Selenium Grid: Capabilities and Platform.WINDOWS7?

但是,由于三个原因,我想发布一个新问题.它处理硒的旧版本.我正在使用2.39.0,该解决方案引用的版本是2.15.另外,我有四个Windows平台,因此除非我删去了部分测试矩阵,否则我将无法使用建议的解决方案.这是不希望的,但并非没有可能.最后,尽管我对所使用的技巧有一个不错的了解,但我对如何覆盖枚举可能会影响我的测试的了解还不得而知.

However I wanted to post a new question for three reasons. It deals with an old version of selenium. I'm using 2.39.0 and the solution references version 2.15. Also, I have four windows platforms, so I can't use the suggested solution unless I gut out part of my test matrix. That is undesirable, but not impossible. Finally, while I have a decent understanding of the trick being used, my understanding of how overriding the enum might affect my tests is pretty big unknown.

我想到的一种可能的解决方法取决于枚举的使用方式.如果它仅使用枚举来搜索所有节点以找到已设置为具有某些指定功能的机器,则可以将其余的平台标志中的任何一个分配给我的第四个OS配置文件.例如,将XP标志分配给winXP,将WINDOWS标志分配给win7,将VISTA分配给win8,最后将UNIX标志分配给win8.1.但是,如果将枚举用于更强烈的目的,那么我将成为众所周知的小河.此外,即使使用正常,使用UNIX平台标志定义Windows框也似乎是不好的编程习惯.

One possible workaround I've thought of depends on how the enum is used. If it just uses the enum to search all the nodes to find a machine that has been set up with some specified capability I could assign any of the remaining platform flags to my fourth OS profile. For instance, assign the XP flag to winXP, WINDOWS flag to win7, VISTA to win8, and finally the UNIX flag to win8.1. But if the enum is used for more intense purposes I'm up the proverbial creek. Also, defining a windows box with a UNIX platform flag just seems like bad programming practice, even if it were to work just fine.

我想我真正想要的是告诉网格在具有此IP地址的计算机上运行此测试"而不是在与这些功能匹配的计算机上运行此测试"的方法.此功能是否已添加到硒中,还是我缺少一种解决方法?

I guess what I really want is way to tell the grid "Run this test on the machine with this IP address" rather than "run this test on a machine that matches these capabilities." Has this functionality been added to selenium, or is there a workaround I'm missing?

谢谢

乔恩

推荐答案

您可以在节点计算机上的节点配置json文件中指定IP:

You can possibly specify the IP in the node configuration json file on your node machine:

{
    "capabilities":
    [
        {
            "platform": "WINDOWS",
            "browserName": "firefox",
            "maxInstances": 1,
            "seleniumProtocol": "WebDriver",
            "nodeip": "192.168.0.123"
        }
    ],
    "configuration":
        {
            "proxy":"org.openqa.grid.selenium.proxy.WebDriverRemoteProxy",
            "maxSession":1,
            "url":"http://192.168.0.99:4444/wd/hub"
        }
}

然后请求特定的节点:

DesiredCapabilities caps = DesiredCapabilities.firefox();   
caps.setCapability("platform", Platform.WINDOWS);
caps.setCapability("nodeip", "192.168.0.123"); 
RemoteWebDriver driver = new RemoteWebDriver(new URL(hubUrl), caps); 

或者,您可以使用applicationName功能或Browser Version功能来指定IP/自定义值,因为硒网格在这些值上进行了简单的字符串匹配.有关使用现有功能识别特定节点的信息,请参见下面的google小组讨论:

Alternatively, you can possibly use the applicationName capability or the Browser Version capability to specify your IP/custom value as selenium grid does a simple string match on these. See the below google group discussions on using existing capabilities for identifying a specific node:

使用applicationName功能

使用Browser Version功能

这篇关于在Selenium Grid中指定Windows版本(或特定计算机)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆