Skip to content

Instantly share code, notes, and snippets.

@johnrc
Created February 27, 2017 04:32
Show Gist options
  • Save johnrc/3c237a11e54eb5a00d567f8d24ef24eb to your computer and use it in GitHub Desktop.
Save johnrc/3c237a11e54eb5a00d567f8d24ef24eb to your computer and use it in GitHub Desktop.
How to use Selenium grid via Docker

Selenium Grid on Docker

Setup Containers

docker run -d -P --name selenium-hub selenium/hub
docker run -d --link selenium-hub:hub selenium/node-chrome
docker exec -it ad6211909835 bash

Quick Test

You can run a quick test using Python:

pip install selenium

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

driver = webdriver.Remote(
   command_executor='http://138.197.5.202:32768/wd/hub',
   desired_capabilities=DesiredCapabilities.CHROME)
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.quit()

Miscellaneous

Here's the url to download Chrome as an RPM: http://dl.google.com/linux/chrome/rpm/stable/x86_64/google-chrome-stable-55.0.2883.87-1.x86_64.rpm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment