[go: nahoru, domu]

Skip to content

Selenium Grid In A Box - All you need for a simplified setup & install of Selenium Grid

Notifications You must be signed in to change notification settings

shchavla/SeleniumGridInABox

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 

Repository files navigation

SeleniumGridInABox

Selenium Grid In A Box - All you need for a simplified setup & install of Selenium Grid with Google Chrome, Mozilla Firefox and Internet Explorer.

What is Selenium Grid In A Box?

Selenium Grid In a Box is designed to make the installation and setup of a multi-browser Selenium Grid on a Windows machine a super-simple process.

Rather than having to download & install the individual components for the Selenium Grid Hub, and each browsers manually, all you need to do is to copy the Selenium Grid In A Box folder to your windows machine, set some environment variables for configuration, and away you go!

It includes :

  • Selenium Grid (Standalone Jar 2.26.0)
  • Mozilla Firefox 16.0.2 (Portable Edition, thanks to PortableApps)
  • Google Chrome 23 (Portable Edition, thanks to PortableApps)
  • Internet Explorer (whichever version available on your Windows machine)
  • JavaSE 7
  • Scripts to install the Selenium Grid Hub, and the above browsers as a service (thanks to Tanuki Java Service Wrapper)

I will keep the components up to date and repackage once they are tested and known to be working together

How do I set up Selenium Grid In A Box?

  1. Download the latest Selenium As A Grid pack as a zip from here

  2. Unpack to your desired install location. In this example, we want to install to C:\SeleniumGridInABox. The folder structure should look like this. alt text

  3. Set the following environment variables to configure Selenium Grid In A Box.

    • Note that these variables tell Selenium Grid In A Box the included Java version as well as the included browsers. This will be handy if you want to upgrade individual components. See later 'How Do I' section in documentation.
    • You may change the value of the variable SEL_GRID_IN_A_BOX_IEDRIVER_PATH to use either 32bit or 64bit to match your machine
Environment Variable Example
SEL_GRID_IN_A_BOX_HUB_URL http://localhost:4445/grid/register
SEL_GRID_IN_A_BOX_JAVA_HOME C:\SeleniumGridInABox\java\jre7
SEL_GRID_IN_A_BOX_CHROME_PATH C:\SeleniumGridInABox\browsers\GoogleChrome23Portable\App\Chrome-bin
SEL_GRID_IN_A_BOX_FFOX_PATH C:\SeleniumGridInABox\browsers\Firefox16.0.2Portable\App\Firefox
SEL_GRID_IN_A_BOX_IEDRIVER_PATH C:\SeleniumGridInABox\browsers\IEDriverServer\32bit
![alt text](http://kennychua.net/wp-content/uploads/2012/12/sgib_environment_variables.png "Example environment variables")
  1. Then, APPEND the following Environment Variables to your PATH Environment Variable
Environment Variable Example
PATH …existing values…;%SEL_GRID_IN_A_BOX_CHROME_PATH%;%SEL_GRID_IN_A_BOX_FFOX_PATH%;%SEL_GRID_IN_A_BOX_IEDRIVER_PATH%
  1. Run the following scripts in install each component as a Windows Service
    • C:\SeleniumGridInABox\_startup_and_install_as_service_scripts\SeleniumHub\InstallSeleniumHubService-NT.bat
    • C:\SeleniumGridInABox\_startup_and_install_as_service_scripts\GoogleChrome\InstallGoogleChromeSeleniumNodeService-NT.bat
    • C:\SeleniumGridInABox\_startup_and_install_as_service_scripts\MozillaFirefox\InstallFirefoxSeleniumNodeService-NT.bat
    • C:\SeleniumGridInABox\_startup_and_install_as_service_scripts\InternetExplorer\InstallInternetExplorerSeleniumNodeService-NT.bat
  2. Your Selenium Grid is now installed! Start the all the Selenium Grid In A Box services and you've got a Grid running. alt text

How do I use Selenium Grid In A Box in my Selenium tests?

When obtaining a Webdriver, specify your DesiredCapability to select one of the browsers on the Grid. Example Java JUnit snippet:

private static WebDriver initGridDriver(final String gridUrl) throws MalformedURLException {
        final DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setBrowserName(System.getProperty("browser", "chrome")); // or
        //capabilities.setBrowserName(System.getProperty("browser", "firefox")); // or
        //capabilities.setBrowserName(System.getProperty("browser", "internet explorer")); 
        return new RemoteWebDriver(new URL(gridUrl), capabilities);
}

How Do I Update …

I'll strive to keep all the components up-to-date with the versions known and tested to work with each other, but if you decide to change things up, here's how…

Java

Simply point the SEL_GRID_IN_A_BOX_JAVA_HOME environment variable to your desired JAVA_HOME

Selenium Jar

Once you have obtained the latest Selenium standalone jar from here, place it in C:\SeleniumGridInABox\selenium_grid_jars. Then symlink C:\SeleniumGridInABox\selenium_grid_jars\selenium-server-standalone-latest.jar to it. This is h ow to do that in a command prompt: mklink C:\SeleniumGridInABox\selenium_grid_jars\selenium-server-standalone-latest.jar C:\SeleniumGridInABox\selenium_grid_jars\selenium-server-standalone-2.25.0.jar

Chrome

Simply point the SEL_GRID_IN_A_BOX_CHROME_PATH environment variable to the path containing your Chrome executable. This directory should also have chromedriver.exe as Selenium needs this to drive Chrome.

Firefox

Simply point the SEL_GRID_IN_A_BOX_FFOX_PATH environment variable to the path containing your Firefox executable.

Notes

  • The Chrome and Firefox browsers included are Portable versions. This means that they do not automatically update themselves when a new version is available, and are contained so that they only write to the disk location where they are run from. This is intentional to preserve the consistency of tests.
  • To uninstall the Windows Services, run the following scripts
    • C:\SeleniumGridInABox\_startup_and_install_as_service_scripts\SeleniumHub\UninstallSeleniumHubService-NT.bat
    • C:\SeleniumGridInABox\_startup_and_install_as_service_scripts\GoogleChrome\UninstallGoogleChromeSeleniumNodeService-NT.bat
    • C:\SeleniumGridInABox\_startup_and_install_as_service_scripts\MozillaFirefox\UninstallFirefoxSeleniumNodeService-NT.bat
    • `C:\SeleniumGridInABox_startup_and_install_as_service_scripts\InternetExplorer\UninstallInternetExplorerSeleniumNodeService-
  • The logs location is relative to where you installed Selenium Grid In A Box. In the above example, logs can be found at C:\SeleniumGridInABox\logs

githalytics.com alpha

FAQ

Will this work when running as a Windows Service on Windows Vista or Windows Server 2008 / Session 0 isolation ?

Absolutely! When running as services, the install scripts have been written so that it spawns browser processes not in the active user's foreground session. Instead, it sends the spawned browsers to Session 0 where they are safe from interfered with by a users Read more about Session 0 isolation, and how to access Session 0 here : http://www.coretechnologies.com/WindowsServices/FAQ.html#

Bitdeli Badge

About

Selenium Grid In A Box - All you need for a simplified setup & install of Selenium Grid

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published