Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Selenium grid workshop london 2016

382 views

Published on

These were the opening slides used in the all-day Selenium Grid Workshop, given by Marcus Merrell and Manoj Kumar on November 14, 2016 at the 2016 London Selenium Conference

Published in: Engineering
  • Be the first to comment

Selenium grid workshop london 2016

  1. 1. Selenium Grid Workshop
  2. 2. Schedule 9:00-9:30 — General Set up: Power Cords, Wi-Fi, Seating, and Introductions 9:30-10:30 — Grid Overview, Basic Concepts & Philosophy 10:30-10:45 — Break 10:45-12:00 — Hub/Node Setup and Config 12:00-1:00 — Lunch 1:30-3:30 — Docker, Troubleshooting, and Advanced Options 3:30-3:45 — Break 3:45-5:00 — Extensions, Plug-ins, Auto-scaling, and Advanced Logging — Q&A, Anecdotes, Discussion, and General Tips & Tricks
  3. 3. Overview ● Terminology ● General Flow ● Hub/Node Details ● Configuration ● Docker Intro ● Edge (if you dare) ● Preview of Next Session https://goo.gl/BWlK1a
  4. 4. Terminology ● Hub ● Node ● Test Slot ● Test ● Thread ● Proxy
  5. 5. Grid 101
  6. 6. Hub ● The intermediary and manager ● Accepts requests to run tests ● Allocates Test Slots to nodes ● Takes instructions directly from client, and executes them remotely on nodes ● The Hub only manages threads—it performs zero browser work
  7. 7. Node - Registers itself to Hub listed in config - Communicates its config to the Hub at registration time: - Test Slots per browser - “Hey Hub, I have 1 Slot for Firefox, 5 for Chrome” - Receives json wire protocol instructions from the Hub - Executes instructions, keeping threads separated - The Node does not evaluate, make judgments, or control anything: it only receives and executes instructions (and throws exceptions)
  8. 8. Start the Hub: java -jar selenium-server-standalone-3.0.1.jar -role hub Register a node: java -jar selenium-server-standalone-3.0.1.jar -role node -hub http://localhost:4444/grid/register -browser browserName=firefox,maxInstances=3 -browser browserName=chrome,maxInstances=5 *All commands are case sensitive! Starting From Command-line
  9. 9. Hub Parameters — Configuration ● -port Default is 4444, use this to override ● -jettyMaxThreads <int> Maximum number of threads server will pool ● -cleanUpCycle <milliseconds> Interval for hub to poll for inactive test sessions
  10. 10. Hub Parameters - Timeouts ● -timeout <seconds> ● -browserTimeout <seconds, min 60> Timeout between receiving individual commands 60 seconds minimum value ● -newSessionWaitTimeout <milliseconds> Timeout the server will wait for a new Session to be created
  11. 11. Hub Parameters — ● -prioritizer Class (on the classpath!) that will be used to sort queued new Session requests Must implement Prioritizer ● -servlets Custom servlets, mainly for grid plugins ● -log <filename>
  12. 12. Hub Parameters — Capabilities ● -throwOnCapabilityNotPresent ● -capabilityMatcher Class that implements CapabilityMatcher DefaultCapabilityMatcher only checks Platform, Browser Name, Version, “applicationName”
  13. 13. Node Command line options ● -nodeConfig <filename> ● -hubHost <DNS entry> ● -hubPort <port> ● -host <localhost> ● -port <local port> ● -maxSession <int> ● -register ● -servlets
  14. 14. Node Parameters — JSON file ● -nodeConfig <filename> { "capabilities": [ { "browserName": "chrome", "maxInstances": 5, "platform": "WINDOWS", "webdriver.chrome.driver": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe" }, ], "configuration": { "_comment" : "Configuration for Node", "cleanUpCycle": 2000, "proxy": "org.openqa.grid.selenium.proxy.WebDriverRemoteProxy", "port": 5555, "host": ip, "register": true, "hubPort": 4444, "maxSessions": 5 } }
  15. 15. Node Command line options ● -browser param1=val1,param2=val2 Usually, only browserName, platform, version, applicationName and maxInstances are important ● -cleanUpCycle <milliseconds> ● -registerCycle <milliseconds> How often the node will try to register itself again. Allows you to restart the hub without having to restart the nodes
  16. 16. Run It! ● We’ll write a quick javascript test ● Use node to run it ● We’ll need: ○ Node (v6.9.0) (brew install node) ○ selenium-webdriver module (npm install -g selenium-webdriver) ○ chromedriver v2.25.426935 ● Paste script (https://goo.gl/sRNVVC) into test.js ● node test.js ● It will go really fast, so be sure to watch!
  17. 17. docker 101 ● docker ps ● docker exec -it <container id> bash ● docker kill <image> ● docker run ● docker images -a ● docker rmi <image> ● docker -p ● docker -P ● docker -d ● docker --link
  18. 18. docker-selenium Standalone Running a standalone machine without connecting to a hub ● selenium/standalone-chrome: Selenium standalone with Chrome installed ● selenium/standalone-firefox: Selenium standalone with Firefox installed ● selenium/standalone-chrome-debug: Selenium standalone with Chrome installed and runs a VNC server ● selenium/standalone-firefox-debug: Selenium standalone with Firefox installed and runs a VNC server
  19. 19. docker-selenium Standalone Start docker instance: Chrome docker run -d -p 4455:4444 selenium/standalone-chrome:2.53.0 Firefox docker run -d -p 4466:4444 selenium/standalone-firefox:2.53.0 docker run -d --name se -p 5900:5900 -p 4444:4444 selenium/standalone-chrome-debug Check they are up and running and you can connect to them! http://localhost:4455/wd/hub/status http://localhost:4466/wd/hub/status Register them to your running hub: https://goo.gl/TE4xuv
  20. 20. docker-selenium GRID ● selenium/hub: Image for running a Selenium Grid Hub ● selenium/node-chrome: Selenium node with Chrome installed, needs to be connected to a Selenium Grid Hub ● selenium/node-firefox: Selenium node with Firefox installed, needs to be connected to a Selenium Grid Hub ● selenium/node-chrome-debug: Selenium node with Chrome installed and runs a VNC server, needs to be connected to a Selenium Grid Hub ● selenium/node-firefox-debug: Selenium node with Firefox installed and runs a VNC server, needs to be connected to a Selenium Grid Hub
  21. 21. docker-selenium GRID ● Creating a docker HUB instance docker run -d -p 5000:4444 --name selenium-hub -P selenium/hub To check if the hub is up and running http://localhost:5000/grid/console ● Run a Chrome Node and Link it to Hub docker run -d --link selenium-hub:hub -P --name chrome selenium/node-chrome-debug ● Run a Firefox Node and Link it to Hub docker run -d --link selenium-hub:hub -P --name firefox selenium/node-firefox-debug
  22. 22. Selenium GRID with docker-compose docker-compose is a YAML file that will help manage your docker services ● Start, stop & rebuild services ● View the status and logs of services. To get a docker-compose yml file: https://goo.gl/puYvnV To spin up Selenium Grid: docker-compose up -d
  23. 23. Q&A Thank You All! Marcus Merrell & Manoj Kumar
  24. 24. Add a Windows VM https://goo.gl/P8q7jT
  25. 25. starting Edge node java -jar selenium-standalone-server-3.0.1.jar -nodeConfig config.json -port 4444 -hub http://<host>:<port>/grid/register -host <ip address of win10 vm> -role node config file: https://goo.gl/LWdsGm
  26. 26. Other Grid Topics Selenium Grid Extras https://github.com/groupon/Selenium-Grid-Extras Selenium Grid Scaler https://github.com/mhardin/SeleniumGridScaler BrowserMob Proxy https://bmp.lightbody.net/
  27. 27. Run Via Saucelabs java > -cp > selenium-server-standalone-3.0.1.jar; > sauce-grid-plugin-1.0.4.jar > org.openqa.grid.selenium.GridLauncher > -role hub > -servlets > com.saucelabs.grid.SauceOnDemandAdminServlet, > com.saucelabs.grid.SauceOnDemandConsoleServlet

×