Specifying Windows Versions (or Specific Machines) in Selenium Grid

亡梦爱人 提交于 2019-11-30 20:58:15

问题


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.

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.

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?

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.

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.

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?

Thanks,

Jon


回答1:


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"
        }
}

And then request the specific node:

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

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:

Using the applicationName capability

Using the Browser Version capability



来源:https://stackoverflow.com/questions/20711021/specifying-windows-versions-or-specific-machines-in-selenium-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!