This repo gives an idea on how to get started with running Selenium-tests using a Virtualized Selenium Grid. This project uses a quite modern approach to make it possible to run Selenium tests against any version of browser in an easy manner.
The following must be installed on your local system aside from enabling VT-x in your BIOS.
- Vagrant
- VirtualBox
- Java 9 SDK (To run the Selenium Remote Test Java Example)
The Grid can be used for development of selenium tests towards any particular browser.
run the following at the root of this maven module
vagrant up
The Vagrantfile is a wrapper for virtualbox that downloads and provisions an image for ubuntu/trusty64 by updating the system and downloads Docker CE
and provisions selenoid
and selenoid-ui
using the selenoid configuration manager.
http://localhost:4444/wd/hub
http://localhost:8080
This default setup of Selenoid comes packaged with two versions of each browser, that is, however highly configurable inside your vagrant machine. vagrant ssh
gets you inside the virtualbox. Consult the Selenoid documentation on how to modify the browsers.json file and restart docker for the new capabilities to take effect.
- Chromes latest and one earlier
- Firefoxs latest and one earlier
- Operas latest and one earlier
Now you can start developing towards the Selenoid grid. This repository contains a single example for triggering a JUnit test using the basic Java bindings towards the selenoid-grid. Implement using your favourite language, IDE and build system.
Or run a clean install of this module.
mvn clean install
public class SeleniumTest {
private WebDriver browser;
@Before
public void setUp() throws Exception {
DesiredCapabilities abilities = DesiredCapabilities.chrome();
this.browser = new RemoteWebDriver( new URL("http://localhost:4444/wd/hub"), abilities);
this.browser.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
this.browser.manage().window().setPosition(new Point(220, 10));
this.browser.manage().window().setSize(new Dimension(1000,650));
}
@Test
public void testSimple() throws Exception {
this.browser.get("http://www.google.com");
assertEquals("Google", this.browser.getTitle());
}
@After
public void tearDown() throws Exception {
this.browser.quit();
}
}
When you have no more need of running selenium-tests you can stop the Vagrant machine using
vagrant halt
or destroy it to have a clean environment for next day using
vagrant destroy