Execute Selenium Test Using Docker

  1. Hypervisor
  2. virtualization
  3. containerization
Viirtualization Enabled
dockerSeleniumGrid.bat
docker run -d -p 4444:4444  --name selenium-hub selenium/hub
docker run -d -p 5900:5900 --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-chrome-debug
docker run -d -p 5901:5900 --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-firefox-debug
run .bat file
batch execution
Selenium grid : http://192.168.99.100:4444/grid/console
Authenticate VNC server
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.MalformedURLException;
import java.net.URL;

public class RemoteDriver {

public static void main(String[] args) throws MalformedURLException, InterruptedException {

DesiredCapabilities capability = DesiredCapabilities.chrome();
WebDriver driver = new RemoteWebDriver(new URL("http://"+"192.168.99.100"+":4444/wd/hub"), capability);
driver.get("http://www.google.com");
driver.findElement(By.cssSelector("input[name='q']")).sendKeys("selenium remote driver execution");
driver.quit();

}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store