{"id":8038,"date":"2021-05-07T14:12:23","date_gmt":"2021-05-07T05:12:23","guid":{"rendered":"https:\/\/www.ecomottblog.com\/?p=8038"},"modified":"2021-05-07T14:12:23","modified_gmt":"2021-05-07T05:12:23","slug":"docker%e3%81%a7selenium-grid%e3%82%92%e6%a7%8b%e7%af%89%e3%81%97%e3%81%a6%e3%82%af%e3%83%ad%e3%82%b9%e3%83%96%e3%83%a9%e3%82%a6%e3%82%b6%e3%83%86%e3%82%b9%e3%83%88%e3%82%92%e8%87%aa%e5%8b%95%e5%8c%96","status":"publish","type":"post","link":"https:\/\/test.ecomottblog.com\/?p=8038","title":{"rendered":"Docker\u3067Selenium Grid\u3092\u69cb\u7bc9\u3057\u3066\u30af\u30ed\u30b9\u30d6\u30e9\u30a6\u30b6\u30c6\u30b9\u30c8\u3092\u81ea\u52d5\u5316\u3059\u308b"},"content":{"rendered":"<p>\u7686\u3055\u3093\u3053\u3093\u306b\u3061\u306f\u30014\u6708\u3067\u5165\u793e2\u5e74\u76ee\u306b\u306a\u308a\u307e\u3057\u305f\u3002<br \/>\nIoT\u30a4\u30f3\u30c6\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u4e8b\u696d\u90e8 \u958b\u767a\u90e8\u306e\u963f\u90e8\u3067\u3059\u3002<\/p>\n<p>\u672c\u65e5\u306f\u696d\u52d9\u306e\u4e2d\u3067\u3001Docker\u3068Selenium Grid\u3092\u4f7f\u7528\u3057\u3066\u81ea\u52d5\u30af\u30ed\u30b9\u30d6\u30e9\u30a6\u30b6\u30c6\u30b9\u30c8\u306e\u74b0\u5883\u69cb\u7bc9\u3092\u3057\u305f\u306e\u3067\u3054\u7d39\u4ecb\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3059\u3002<\/p>\n<p>\u30d6\u30e9\u30a6\u30b6\u4e0a\u3067\u306eweb\u30da\u30fc\u30b8\u64cd\u4f5c\u3092\u30b9\u30af\u30ea\u30d7\u30c8\u304b\u3089\u884c\u3046\u305f\u3081\u306e\u30c4\u30fc\u30eb\u3067\u3042\u308bSelenium\u3068Selenium\u3067\u5b9f\u884c\u3055\u308c\u308b\u52d5\u4f5c\u3092\u7ba1\u7406\u3059\u308b\u30c4\u30fc\u30eb\u3067\u3042\u308bSelenium Grid\u3092\u5229\u7528\u3057\u3001\u4e00\u3064\u306e\u30c6\u30b9\u30c8\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u8907\u6570\u306e\u30d6\u30e9\u30a6\u30b6\u3092\u81ea\u52d5\u3067\u30c6\u30b9\u30c8\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<h2>Selenium Grid \u3068\u306f<\/h2>\n<p>\u8907\u6570\u30de\u30b7\u30f3\u3067\u30c6\u30b9\u30c8\u3092\u4e26\u884c\u3057\u3066\u5b9f\u884c\u3057\u3001\u69d8\u3005\u306a\u30d6\u30e9\u30a6\u30b6\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3068\u30d6\u30e9\u30a6\u30b6\u69cb\u6210\u3092\u4e00\u5143\u7ba1\u7406\u3059\u308b\u30c4\u30fc\u30eb\u3067\u3059\u3002<\/p>\n<p>\u6d41\u308c\u3068\u3057\u3066\u306f\u3001\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3057\u305f\u3044\u30d6\u30e9\u30a6\u30b6\u3092\u6307\u5b9a\u3057\u3066\u3001\u30c6\u30b9\u30c8\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001hub\u304c\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3059\u308b\u3053\u3068\u3067\u767b\u9332\u3055\u308c\u3066\u3044\u308bnode\u306e\u4e2d\u304b\u3089\u9069\u5207\u306anode\u306b\u5bfe\u3057\u3066\u51e6\u7406\u3092\u632f\u308a\u5206\u3051\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306fDocker\u3067\u4ee5\u4e0b\u306e\u69cb\u6210\u56f3\u306e\u3088\u3046\u306b\u69cb\u7bc9\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u81ea\u52d5\u30c6\u30b9\u30c8\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3059\u308b\u30b3\u30f3\u30c6\u30ca(3)<\/li>\n<li>hub\u3092\u8d77\u52d5\u3059\u308b\u30b3\u30f3\u30c6\u30ca(1)<\/li>\n<li>node\u3092\u8d77\u52d5\u3059\u308b\u30b3\u30f3\u30c6\u30ca(3)<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8069\" src=\"https:\/\/www.ecomottblog.com\/cmswp\/wp-content\/uploads\/2021\/05\/selenium-grid.png\" alt=\"\" width=\"1280\" height=\"720\" srcset=\"https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/selenium-grid.png 1280w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/selenium-grid-300x169.png 300w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/selenium-grid-768x432.png 768w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/selenium-grid-1024x576.png 1024w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/selenium-grid-304x171.png 304w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/selenium-grid-282x159.png 282w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<h2>\u958b\u767a\u74b0\u5883<\/h2>\n<p>WSL2\u3092\u5c0e\u5165\u3057\u3066\u305d\u306e\u4e0a\u306bUbuntu\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001Docker\u74b0\u5883\u3092\u69cb\u7bc9\u3057\u3066\u3042\u308a\u307e\u3059\u3002<br \/>\n\u203bUbuntu\u4e0a\u306b\u5165\u3063\u3066\u3044\u308b<a href=\"https:\/\/docs.docker.com\/engine\/install\/ubuntu\/\">docker<\/a>\u3068<a href=\"https:\/\/docs.docker.com\/compose\/install\/\">docker-compose<\/a>\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f\u3001\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u66f8\u304b\u308c\u3066\u3044\u308b\u624b\u9806\u3067\u66f4\u65b0\u3057\u3066\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>Ubuntu : 20.04<\/li>\n<li>Docker Desktop\uff1a3.3.1<\/li>\n<li>Docker Engine : 20.10.6<\/li>\n<li>Docker-compose : 1.29.1<\/li>\n<li>Python\uff1a3.8<\/li>\n<\/ul>\n<h2>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210<\/h2>\n<pre class=\"lang:default decode:true\">.\n\u251c\u2500 app\n\u3000\u3000\u251c\u2500 screenshot (\u30c6\u30b9\u30c8\u30b9\u30af\u30ea\u30d7\u30c8\u5b9f\u884c\u5f8c\u306b\u751f\u6210)\n\u3000\u3000\u3000\u3000\u251c\u2500 chrome\n\u3000\u3000\u3000\u3000\u251c\u2500 firefox\n\u3000\u3000\u3000\u3000\u2514\u2500 edge\n\u3000\u3000\u251c\u2500 Dockerfile\n\u3000\u3000\u251c\u2500 requirements.txt\n\u3000\u3000\u2514\u2500 browser_test.py\n\u2514\u2500 docker-compose.yml<\/pre>\n<h2>\u30c6\u30b9\u30c8\u30b9\u30af\u30ea\u30d7\u30c8\u4f5c\u6210<\/h2>\n<p>\u30c6\u30b9\u30c8\u30b9\u30af\u30ea\u30d7\u30c8(browser_test.py)\u306f\u30cf\u30d6\u306b\u63a5\u7d9a\u3057\u3066\u3001\u30d8\u30c3\u30c9\u30ec\u30b9\u30e2\u30fc\u30c9\u3067\u30d6\u30e9\u30a6\u30b6\u3092\u64cd\u4f5c\u3059\u308b\u51e6\u7406\u3092Python\u3067\u8a18\u8ff0\u3057\u307e\u3059\u3002\u4eca\u56de\u306f\u30a8\u30b3\u30e2\u30c3\u30c8\u306e\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u30c6\u30b9\u30c8\u3059\u308b\u30d6\u30e9\u30a6\u30b6\u306b\u3088\u3063\u3066Remote WebDriver\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u5909\u66f4\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u3001\u30b3\u30f3\u30c6\u30ca\u306b\u8a2d\u5b9a\u3059\u308b\u74b0\u5883\u5909\u6570\u3092\u5229\u7528\u3057\u3066\u5909\u66f4\u3057\u307e\u3059\u3002\u307e\u305f\u3001\u30c6\u30b9\u30c8\u306e\u30a8\u30d3\u30c7\u30f3\u30b9\u3092\u6b8b\u3059\u305f\u3081\u306b\u3001\u30c6\u30b9\u30c8\u5b9f\u884c\u5f8c\u306e\u753b\u9762\u3092\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u3057\u3066\u4fdd\u5b58\u3059\u308b\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:python decode:true\" title=\"browser_test.py\">from selenium import webdriver\nimport os\nimport json\n\n# \u30b3\u30f3\u30c6\u30ca\u306b\u767b\u9332\u3057\u305f\u74b0\u5883\u5909\u6570\u306e\u8a2d\u5b9a\nBROWSER_NAME = os.environ['BROWSER_NAME']\nHOST_NAME = os.environ['HUB_HOST']\n\n# \u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u4fdd\u5b58\u3059\u308b\u305f\u3081\u306e\u30d1\u30b9\u3092\u30d6\u30e9\u30a6\u30b6\u3054\u3068\u306b\u6307\u5b9a\nBROWSER_FILE_PATH = \"screenshot\/\" + BROWSER_NAME + \"\/\"\nCURRENT_DIR_PATH = os.path.dirname(os.path.abspath(__file__))\n\n# \u30c6\u30b9\u30c8\u6642\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u4fdd\u5b58\u3059\u308b\u305f\u3081\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\nif not os.path.exists(os.path.join(CURRENT_DIR_PATH, BROWSER_FILE_PATH)):\n    os.makedirs(os.path.join(CURRENT_DIR_PATH, BROWSER_FILE_PATH))\n\n# \u30c6\u30b9\u30c8\u3059\u308b\u30d6\u30e9\u30a6\u30b6\u3054\u3068\u306bwebdriver\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\nif BROWSER_NAME == \"chrome\":\n    options = webdriver.ChromeOptions()\nelif BROWSER_NAME == \"firefox\":\n    options = webdriver.FirefoxOptions()\nelse:\n    options = webdriver.EdgeOptions()\n    options.use_chromium = True\nprint(BROWSER_NAME)\n\n# \u753b\u9762\u3092\u8868\u793a\u3057\u306a\u3044\u306e\u3067\u3042\u308c\u3070\u3001\u30d8\u30c3\u30c9\u30ec\u30b9\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4ed8\u3051\u308b\noptions.add_argument('--headless')\noptions.add_argument('--window-size=1280,1024')\n\n# Selenium hub Server\u306b\u63a5\u7d9a\u3059\u308b\nwith webdriver.Remote(\n    command_executor=f'http:\/\/{HOST_NAME}:4444\/wd\/hub',\n    desired_capabilities=options.to_capabilities(),\n    options=options,\n) as driver:\n    # \u30d6\u30e9\u30a6\u30b6\u3092\u64cd\u4f5c\u3059\u308b\n    driver.get('https:\/\/www.ecomott.co.jp\/')\n    print(driver.current_url)\n\n    # \u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u53d6\u3063\u3066\u4fdd\u5b58\n    driver.save_screenshot(os.path.join(CURRENT_DIR_PATH, BROWSER_FILE_PATH + \"test.png\"))<\/pre>\n<h2>Dockerfile\u4f5c\u6210<\/h2>\n<p>Selenium\u5b9f\u884c\u74b0\u5883\u3092\u7528\u610f\u3059\u308b\u305f\u3081\u306bPython\u306e\u30d9\u30fc\u30b9\u30a4\u30e1\u30fc\u30b8\u3092\u4f7f\u7528\u3057\u3066\u3001Selenium\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">FROM python:3.8\n\nRUN apt-get -y update &amp;&amp; \\\n&nbsp;&nbsp;&nbsp; python -m pip install --upgrade pip\n\nADD requirements.txt .\n\nRUN pip install -r requirements.txt\n\nWORKDIR \/app<\/pre>\n<h2>reqirements.txt\u4f5c\u6210<\/h2>\n<p>\u81ea\u52d5\u30c6\u30b9\u30c8\u306e\u69d8\u5b50\u3092GUI\u3067\u78ba\u8a8d\u3059\u308b\u5834\u5408\u306f\u3001VNC\u63a5\u7d9a\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002Edge\u306b\u306f\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u304c\u3001Chrome\u3068Firefox\u306b\u306fVNC\u30b5\u30fc\u30d0\u30fc\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u30a4\u30e1\u30fc\u30b8\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u308b\u306e\u3067GUI\u3067\u52d5\u4f5c\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3057\u304b\u3057\u3001VNC\u30b5\u30fc\u30d0\u30fc\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u30a4\u30e1\u30fc\u30b8\u306fSelenium\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c3\u7cfb\u3067\u306a\u3044\u3068\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u305f\u3081\u3001\u30c7\u30d0\u30c3\u30b0\u3092\u884c\u3046\u969b\u306fSelenium\u306e3\u7cfb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u5408\u308f\u305b\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u52d5\u4f5c\u78ba\u8a8d\u3092\u3059\u308b\u969b\u306eviewer\u306f\u3001<a href=\"https:\/\/www.realvnc.com\/en\/connect\/download\/viewer\/\">VNCviewer<\/a>\u3084<a href=\"https:\/\/forest.watch.impress.co.jp\/library\/software\/ultravnc\/\">UltraVNC<\/a>\u306a\u3069\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">selenium==4.0.0-beta-3\n# GUI\u3067\u78ba\u8a8d\u3059\u308b\u6642\u306fselenium3\u3092\u5229\u7528\u3059\u308b\uff08VNC\u63a5\u7d9a\u7528\uff09\n# selenium<\/pre>\n<h2>docker-compose.yml\u4f5c\u6210<\/h2>\n<p>Selenium\u5b9f\u884c\u74b0\u5883\u3068\u3001Selenium\u306e\u30cf\u30d6\u3001\u30d6\u30e9\u30a6\u30b6\u3092\u8d77\u52d5\u3059\u308b\u30ce\u30fc\u30c9\u306e\u30b3\u30f3\u30c6\u30ca\u3092\u8a18\u8ff0\u3057\u3066\u3044\u304d\u307e\u3059\u3002\u30cf\u30d6\u3068\u30ce\u30fc\u30c9\u306f\u3001Selenium\u304c\u5c55\u958b\u3057\u3066\u3044\u308b\u516c\u5f0f\u306eDocker\u30a4\u30e1\u30fc\u30b8\u3092\u4f7f\u3046\u3068\u7c21\u5358\u306b\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/SeleniumHQ\/docker-selenium\">https:\/\/github.com\/SeleniumHQ\/docker-selenium<\/a><\/p>\n<p>\u30ce\u30fc\u30c9\u306e\u30a4\u30e1\u30fc\u30b8\u306f\u3001\u65e2\u306b\u30d6\u30e9\u30a6\u30b6\u3068WebDriver\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u30ed\u30fc\u30ab\u30eb\u3067\u69cb\u7bc9\u3059\u308b\u3068\u304d\u306b\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u5408\u308f\u305b\u306a\u3044\u3068\u52d5\u4f5c\u3057\u306a\u3044\u3068\u3044\u3046\u624b\u9593\u3092\u7701\u3051\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306fChrome\u3068Firefox\u3001Edge\u3067\u30c6\u30b9\u30c8\u3092\u3059\u308b\u305f\u3081\u306b\u3001Selenium\u5b9f\u884c\u74b0\u5883\u3068\u30ce\u30fc\u30c9\u30b3\u30f3\u30c6\u30ca\u3092\u305d\u308c\u305e\u308c3\u3064\u7528\u610f\u3057\u3001\u30cf\u30d6\u3068\u5408\u308f\u305b\u3066\u5408\u8a087\u3064\u306e\u30b3\u30f3\u30c6\u30ca\u3092\u7acb\u3061\u4e0a\u3052\u307e\u3059\u3002\u307e\u305f\u3001VNC\u63a5\u7d9a\u3092\u3057\u3066\u30c7\u30d0\u30c3\u30b0\u3092\u884c\u3046\u969b\u306f\u3001\u30ce\u30fc\u30c9\u30b3\u30f3\u30c6\u30ca\u3067VNC\u63a5\u7d9a\u7528\u30dd\u30fc\u30c8(5900)\u3092\u89e3\u653e\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">version: '3.8'\n\nservices:\n  selenium-hub:\n    image: selenium\/hub:4.0.0\n    # VNC\u63a5\u7d9a\u7528\n    # image: selenium\/hub:3.141\n    ports:\n      - 4444:4444\n      - 4442:4442\n      - 4443:4443\n\n  node-chrome:\n    image: selenium\/node-chrome:4.0.0\n    # VNC\u63a5\u7d9a\u7528\n    # image: selenium\/node-chrome-debug:3.141\n    # ports:\n    #   - 5900:5900\n    volumes:\n      - \/dev\/shm:\/dev\/shm\n    depends_on:\n      - selenium-hub\n    environment:\n      - TZ=Asia\/Tokyo\n      - HUB_HOST=selenium-hub\n      # hub\u3068\u306e\u63a5\u7d9a\u3067\u5fc5\u8981\n      - SE_EVENT_BUS_HOST=selenium-hub\n      - SE_EVENT_BUS_PUBLISH_PORT=4442\n      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443\n      # \u540c\u6642\u5b9f\u884c\u6570\u3092\u5897\u3084\u3059\u5834\u5408\u306b\u8a2d\u5b9a\u3092\u884c\u3046\n      # - SE_NODE_MAX_SESSIONS=2\n      # - SE_NODE_OVERRIDE_MAX_SESSIONS=true\n\n  node-firefox:\n    image: selenium\/node-firefox:4.0.0\n    # VNC\u63a5\u7d9a\u7528\n    # image: selenium\/node-firefox-debug:3.141\n    # ports:\n    #   - 5901:5900\n    volumes:\n      - \/dev\/shm:\/dev\/shm\n    depends_on:\n      - selenium-hub\n    environment:\n      - TZ=Asia\/Tokyo\n      - HUB_HOST=selenium-hub\n      - SE_EVENT_BUS_HOST=selenium-hub\n      - SE_EVENT_BUS_PUBLISH_PORT=4442\n      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443\n\n  node-edge:\n    image: selenium\/node-edge:4.0.0\n    volumes:\n      - \/dev\/shm:\/dev\/shm\n    depends_on:\n      - selenium-hub\n    environment:\n      - TZ=Asia\/Tokyo\n      - HUB_HOST=selenium-hub\n      - SE_EVENT_BUS_HOST=selenium-hub\n      - SE_EVENT_BUS_PUBLISH_PORT=4442\n      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443\n\n\n  python-selenium-for-chrome:\n    build: .\/app\n    image: python\/selenium_chrome\n    # VNC\u63a5\u7d9a\u7528\n    # image: python\/selenium_chrome:debug\n    volumes:\n      - .\/app:\/app\n    depends_on:\n      - selenium-hub\n    tty: true\n    environment:\n      - HUB_HOST=selenium-hub\n      - BROWSER_NAME=chrome\n    # \u30b3\u30f3\u30c6\u30ca\u521d\u56de\u8d77\u52d5\u6642\u306b\u30c6\u30b9\u30c8\u5b9f\u884c\n    # entrypoint: .\/entry_point.sh\n\n  python-selenium-for-firefox:\n    build: .\/app\n    image: python\/selenium_firefox\n    # VMC\u63a5\u7d9a\u7528\n    # image: python\/selenium_firefox:debug\n    volumes:\n      - .\/app:\/app\n    depends_on:\n      - selenium-hub\n    tty: true\n    environment:\n      - HUB_HOST=selenium-hub\n      - BROWSER_NAME=firefox\n    # entrypoint: .\/entry_point.sh\n\n  python-selenium-for-edge:\n    build: .\/app\n    image: python\/selenium_edge\n    volumes:\n      - .\/app:\/app\n    depends_on:\n      - selenium-hub\n    tty: true\n    environment:\n      - HUB_HOST=selenium-hub\n      - BROWSER_NAME=edge\n    # entrypoint: .\/entry_point.sh<\/pre>\n<h2>\u30a4\u30e1\u30fc\u30b8\u4f5c\u6210<\/h2>\n<p>\u4f5c\u6210\u3057\u305fDockerfile, requirement.txt, docker-compose.yml\u3092\u3082\u3068\u306b\u30a4\u30e1\u30fc\u30b8\u3092\u30d3\u30eb\u30c9\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">$ docker-compose build<\/pre>\n<h2>\u30b3\u30f3\u30c6\u30ca\u8d77\u52d5<\/h2>\n<p>\u4f5c\u6210\u3057\u305f\u30a4\u30e1\u30fc\u30b8\u3092\u3082\u3068\u306b\u30b3\u30f3\u30c6\u30ca\u3092\u4f5c\u6210\u3057\u3066\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">$ docker-compose up -d<\/pre>\n<h2>\u30c6\u30b9\u30c8\u5b9f\u884c<\/h2>\n<p>\u7acb\u3061\u4e0a\u304c\u3063\u305fSelenium\u5b9f\u884c\u74b0\u5883\u306e\u30b3\u30f3\u30c6\u30ca\u306b\u30b7\u30a7\u30eb\u3092\u30a2\u30bf\u30c3\u30c1\u3057\u3001Python\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">$ docker exec -it [\u30b3\u30f3\u30c6\u30ca\u540d or \u30b3\u30f3\u30c6\u30caID] bash\n\n\/app# python browser_test.py<\/pre>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u53d6\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>Chrome<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8066\" src=\"https:\/\/www.ecomottblog.com\/cmswp\/wp-content\/uploads\/2021\/05\/chrome.png\" alt=\"\" width=\"1280\" height=\"1024\" srcset=\"https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/chrome.png 1280w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/chrome-300x240.png 300w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/chrome-768x614.png 768w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/chrome-1024x819.png 1024w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/chrome-268x214.png 268w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/chrome-282x226.png 282w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<p>Firefox<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8068\" src=\"https:\/\/www.ecomottblog.com\/cmswp\/wp-content\/uploads\/2021\/05\/firefox.png\" alt=\"\" width=\"1366\" height=\"694\" srcset=\"https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/firefox.png 1366w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/firefox-300x152.png 300w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/firefox-768x390.png 768w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/firefox-1024x520.png 1024w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/firefox-304x154.png 304w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/firefox-282x143.png 282w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/p>\n<p>Edge<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8067\" src=\"https:\/\/www.ecomottblog.com\/cmswp\/wp-content\/uploads\/2021\/05\/edge.png\" alt=\"\" width=\"1280\" height=\"1024\" srcset=\"https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/edge.png 1280w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/edge-300x240.png 300w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/edge-768x614.png 768w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/edge-1024x819.png 1024w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/edge-268x214.png 268w, https:\/\/test.ecomottblog.com\/wp-content\/uploads\/2021\/05\/edge-282x226.png 282w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u307e\u305f\u3001\u6bce\u56de\u30b7\u30a7\u30eb\u3092\u30a2\u30bf\u30c3\u30c1\u3057\u3066\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u306e\u306f\u624b\u9593\u304c\u304b\u304b\u308a\u3001\u30b3\u30f3\u30c6\u30ca\u8d77\u52d5\u6642\u306b\u30c6\u30b9\u30c8\u3092\u81ea\u52d5\u5b9f\u884c\u3055\u305b\u305f\u3044\u3068\u3044\u3046\u5834\u5408\u3082\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u305d\u306e\u5834\u5408\u306fdocker-compose.yml\u3067Selenium\u5b9f\u884c\u74b0\u5883\u306e\u8a18\u8ff0\u306bentrypoint\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">entrypoint: .\/entry_point.sh<\/pre>\n<p>\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(enrty_point.sh)\u306e\u5185\u5bb9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u3053\u3067\u30cf\u30de\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u30b3\u30f3\u30c6\u30ca\u8d77\u52d5\u76f4\u5f8c\u306b\u30c6\u30b9\u30c8\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3059\u308b\u3068\u30cf\u30d6\u3068\u30ce\u30fc\u30c9\u304c\u63a5\u7d9a\u5b8c\u4e86\u3057\u3066\u3044\u306a\u3044\u72b6\u614b\u3067\u51e6\u7406\u304c\u8d70\u308a\u3001\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u63a5\u7d9a\u5f85\u6a5f\u6642\u9593\u3092\u8a2d\u3051\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">#!\/bin\/sh\n\n# selenium hub\u3068node\u306e\u63a5\u7d9a\u5f85\u6a5f\u6642\u9593\nsleep 10s\n\necho '========== test start =========='\npython browser_test.py\necho '========== test finish =========='<\/pre>\n<p>\u30c6\u30b9\u30c8\u304c\u7d42\u4e86\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u305f\u3089\u3001\u30b3\u30f3\u30c6\u30ca\u3092\u7d42\u4e86\u3057\u3001\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">$ docker-compose down<\/pre>\n<p>&nbsp;<\/p>\n<h1>\u3055\u3044\u3054\u306b<\/h1>\n<p>\u81ea\u52d5\u5316\u3084\u5c5e\u4eba\u6027\u3092\u6392\u9664\u3059\u308b\u30b7\u30b9\u30c6\u30e0\u3092\u69cb\u7bc9\u3092\u3059\u308b\u3053\u3068\u304c\u597d\u304d\u306a\u306e\u3067\u3068\u3066\u3082\u697d\u3057\u304b\u3063\u305f\u3067\u3059\u3002\u3055\u3089\u306b\u767a\u5c55\u3055\u305b\u3066\u3001AWS\u3092\u5229\u7528\u3057\u3066\u30b3\u30fc\u30c9\u3092push\u3057\u305f\u3089\u30af\u30ed\u30b9\u30d6\u30e9\u30a6\u30b6\u30c6\u30b9\u30c8\u3092\u81ea\u52d5\u3067\u5b9f\u884c\u3059\u308b\u3088\u3046\u306aCI\u74b0\u5883\u3092\u69cb\u7bc9\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h1>\u53c2\u8003\u8cc7\u6599<\/h1>\n<p>seleniumgrid \u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<br \/>\n<a href=\"https:\/\/www.selenium.dev\/documentation\/en\/grid\/\">https:\/\/www.selenium.dev\/docmentation\/en\/grid\/<\/a><\/p>\n<p>Web UI\u30c6\u30b9\u30c8\u81ea\u52d5\u5316\u306e\u5b9f\u884c\u74b0\u5883\u3092Selenium Grid\u3067<br \/>\n<a href=\"https:\/\/techblog.zozo.com\/entry\/qa-webui-test-automation-01\">https:\/\/techblog.zozo.com\/entry\/qa-webui-test-automation-01<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7686\u3055\u3093\u3053\u3093\u306b\u3061\u306f\u30014\u6708\u3067\u5165\u793e2\u5e74\u76ee\u306b\u306a\u308a\u307e\u3057\u305f\u3002 IoT\u30a4\u30f3\u30c6\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u4e8b\u696d\u90e8 \u958b\u767a\u90e8\u306e\u963f\u90e8\u3067\u3059\u3002 \u672c\u65e5\u306f\u696d\u52d9\u306e\u4e2d\u3067\u3001Docker\u3068Selenium Grid\u3092\u4f7f\u7528\u3057\u3066\u81ea\u52d5\u30af\u30ed\u30b9\u30d6\u30e9\u30a6\u30b6\u30c6\u30b9\u30c8\u306e\u74b0\u5883\u69cb\u7bc9\u3092\u3057\u305f\u306e\u3067\u3054\u7d39\u4ecb [&hellip;]<\/p>\n","protected":false},"author":86,"featured_media":8043,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[59,105,106],"_links":{"self":[{"href":"https:\/\/test.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/posts\/8038"}],"collection":[{"href":"https:\/\/test.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/test.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/test.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/users\/86"}],"replies":[{"embeddable":true,"href":"https:\/\/test.ecomottblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8038"}],"version-history":[{"count":31,"href":"https:\/\/test.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/posts\/8038\/revisions"}],"predecessor-version":[{"id":8083,"href":"https:\/\/test.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/posts\/8038\/revisions\/8083"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/test.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/media\/8043"}],"wp:attachment":[{"href":"https:\/\/test.ecomottblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8038"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/test.ecomottblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8038"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/test.ecomottblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8038"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}