views:

992

answers:

2

I'm having a hard time trying to grasp some concepts on selenium Grid/RC. What I need is to provide specific environments (ie6-on-xp, ie7-on-xp, etc) to the tests. For what I've been reading, the browser line in grid_configuration.yml do not make any reference of what version of MSIE or Firefox I'm running. So I can't get my head around in which form I can tell Grid/RC that I want some specific browsers and the path to run them (how RC knows which exe to run?)

Second, I'd like to run portable versions of those browsers. I've only seen that specified in the tests, and not in the RC's command line to run them. That is the way to do it, per test?

+5  A: 

I will answer your question by breaking up the info that you need

What I need is to provide specific environments (ie6-on-xp, ie7-on-xp, etc) to the tests.

Well since you can't have multiple IE instances on the same machine, I know there are apps that allow you to do that but in my experience they cause more issues than solving them. Ideally you want different machines to run the tests. By doing this you are also setting up a selenium farm for your devs to use because they can target a test at a specific instance. So setting up Grid as an Infrastructure is a good step.

For what I've been reading, the browser line in grid_configuration.yml do not make any reference of what version of MSIE or Firefox I'm running. So I can't get my head around in which form I can tell Grid/RC that I want some specific browsers and the path to run them (how RC knows which exe to run?)

The YAML just lets you know what the grid can handle. When starting up the grid you need to make sure that you pass in similar configurations. Think of Se:GRID like you would Se:RC except you don't care where the RC server is because you speak to a central place that works the rest out for you.

If you need it to run tests against a specific items then you will need to handle this in your test setup. There is a common misconception that all tests will run the same in every single browser. This will happen if you never rely on XPath or CSS selectors in your tests because browsers always handle this slightly differently and the slight differences can lead to flaky tests which should always be avoided.

One way to specify which browser to use for a test is to have a central configuration file. In C# this would be using the app.config that has a collection for each browser and doing

Config

<Firefox>
 <addKey browserVersion='3.5.6' OS='WindowsXP'>
</Firefox>

Central Config Class looking inside 1 element

 public class BoothElement : ConfigurationElement
    {
        [ConfigurationProperty("browserVersion", DefaultValue = "", IsKey = true, IsRequired = true)]
        public string browserVersion
        {
            get
            {
                return ((string)(base["browserVersion"]));
            }
            set
            {
                base["browserVersion"] = value;

            }
        }

Tests

selenium = new DefaultSelenium(HubPort, HubPort, browserVersion, SUTServer);
selenium.Open("/test.htm");
//Rest of the test

In python you could create an Array in a module that you include on all your tests

include.py

hubServer = 'hub'
hubPort = 5555
sut = 'http://serverUnderTest'
firefox = [hubServer,hubPort,"\*chrome",sut]
iexplore = [hubServer,hubPort,"\*iehta",sut]

test.py

sel = selenium(firefox)
sel.open("/test.html")
#rest of the test

When using Selenium Grid try thinking of it more as a test infrastructure help framework and hopefully that will help you a little more.

Second, I'd like to run portable versions of those browsers. I've only seen that specified in the tests, and not in the RC's command line to run them. That is the way to do it, per test?

I have never tried to get Selenium to work on mobile browsers and don't think it would work to well, however with Selenium 2 which is currently in alpha there is android support for testing apps.

EDIT FROM COMMENT

   - name:    "Firefox on OS X"
     browser: "*firefox"
   - name:    "Firefox on Linux"
     browser: "*firefox"
   - name:    "IE on Windows"
     browser: "*iehta"
   - name:    "Safari on OS X"
     browser: "*safari"

So say we have the above setup, according to the YAML file we have a number of different *firefox instances. So to call those different ones in our tests our browser setup command would look like

selenium.Start(hubHost, hubPort, "Firefox on Linux", "http://serverUnderTest"); or selenium.Start(hubHost, hubPort, "Firefox on OS X", "http://serverUnderTest");

The hub will translate that into *firefox for you. I prefer having very granular names for my environment instead of the usual *firefox so that if there is a failure its easier to spot where it was and on which specific browser.

AutomatedTester
+1 for using different machines to deal with the IE versions. Save yourself the trouble and avoid that headache.Consider using cheap thin-clients or off-lease machines to keep the costs down.
Peter Bernier
AutomatesTester, first of all thank you very much for your reply.I get now the point in grid_configuration.yml. One thing that's not clear at all for me is the browser line. Does it contains the command line to execute the browser? My point is, if two environments share the same browser (browser: "*firefox") how would i know wich version of ff is?
Nick
answered the question in your comment at the end of my original answer.
AutomatedTester
+1  A: 

Virtual machines can be very handy for setting up "inexpensive" mules in the Selenium Grid farm.

Peter Loron