diff --git a/.env b/.env new file mode 100644 index 0000000..e7f1e5f --- /dev/null +++ b/.env @@ -0,0 +1,6 @@ + +# Use this for standard computers +CHROME_NODE_IMAGE=selenium/node-chrome:103.0 + +# Use this for MacOs M1 / Arm computers +# CHROME_NODE_IMAGE=seleniarm/node-chromium:103.0 diff --git a/.gitignore b/.gitignore index 8187d14..3001e4b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,7 @@ selenium-screenshot-*.png *.pyc venv +healenium_db + # MacOs specifics .DS_Store \ No newline at end of file diff --git a/README.md b/README.md index f9defab..ffe8a3b 100644 --- a/README.md +++ b/README.md @@ -20,30 +20,22 @@ We would be happy to know your comments or issues on following e-mail: lucie.lav 3. **install required libraries** using pip: - `pip install -r requirements.txt` 4. install and **run Docker Desktop**: https://www.docker.com/products/docker-desktop -5. in the project directory, start commandline terminal and **start the Healenium Docker containers** using following commands: +5. modify `.env` file to use proper image - Mac M1 users need to use different image +6. in the project directory, start commandline terminal and **start the Healenium Docker containers** using following commands: + - `docker-compose up -d` - download Docker images and create containers - `docker ps` - list the created containers -Before running `docker-compose up -d`` on MacOs comment out lines 9 and 10: - -```yaml -volumes: - - ./db/sql/init.sql:/docker-entrypoint-initdb.d/init.sql -``` - -New version of the lines should look like: - -```yaml -# volumes: -# - ./db/sql/init.sql:/docker-entrypoint-initdb.d/init.sql -``` - -9. verify that following **containers are up and running** (either in the previous terminal output or directly in Docker Desktop client): - - healenium/hlm-backend - - postgres:11-alpine +7. verify that following **containers are up and running** (either in the previous terminal output or directly in Docker Desktop client): - healenium/hlm-proxy - - healenium/hlm-selenium-4-standalone-xpra + - healenium/hlm-backend - healenium/hlm-selector-imitator + - selenium/hub + - selenium/node-chrome + - selenium/node-firefox + - selenium/node-edge + - postgres:11-alpine + - postgres:11-alpine (exited) ## How to execute tests @@ -51,4 +43,9 @@ Using commandline from project root: - `robot -d results tests/healenium_test.robot` -To see the test execution, you can open http://localhost:8086 in your browser (replace localhost by the name of your server if running remotely) +To see the test execution, you can open http://localhost:4444 in your browser + +# Troubleshooting + +In case you are getting error: `ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))` run sample tests with direct connection to selenium grid: `${selenium_grid_url} http://localhost:4444`. +It has to result for all browsers with first test passed and second test failed. diff --git a/docker-compose.yaml b/docker-compose.yaml index 9bcecc7..63d3d38 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,18 +1,38 @@ version: "3.9" -services: +services: db: image: postgres:11-alpine ports: - "5432:5432" - # Comment out following lines (volumes) when you run on macOs Docker Desktop volumes: - - ./db/sql/init.sql:/docker-entrypoint-initdb.d/init.sql + - ./healenium_db:/var/lib/postgresql/data restart: always environment: - POSTGRES_DB=healenium - POSTGRES_USER=healenium_user - POSTGRES_PASSWORD=YDk2nmNs4s9aCP6K + healthcheck: + test: ["CMD-SHELL", "pg_isready -d healenium -U healenium_user"] + interval: 10s + timeout: 120s + retries: 10 + networks: + - healenium + + dbinit: + image: postgres:11-alpine + environment: + PGUSER: healenium_user + PGPASSWORD: YDk2nmNs4s9aCP6K + PGDATABASE: healenium + PGHOST: db + volumes: + - ./db/sql/init.sql:/var/lib/postgresql/init.sql + depends_on: + db: + condition: service_healthy + command: psql -f /var/lib/postgresql/init.sql networks: - healenium @@ -41,31 +61,70 @@ services: - healenium hlm-proxy: - image: healenium/hlm-proxy:0.2.5 + image: healenium/hlm-proxy:1.0.0 container_name: hlm-proxy volumes: - docker-log-volume:/var/log/dockerlogs ports: - "8085:8085" environment: - - "recovery-tries=1" - - "score-cap=.6" - - "heal-enabled=true" -# - SELENIUM_HOST=hlm-selenium-webview -# - HEALENIUM_HOST=healenium -# - IMITATE_HOST=selector-imitator + - RECOVERY_TRIES=1 + - SCORE_CAP=.6 + - HEAL_ENABLED=true + - SELENIUM_HOST=selenium-hub + - HEALENIUM_HOST=healenium + - IMITATE_HOST=selector-imitator + - SELENIUM_URL=/wd/hub networks: - healenium - hlm-selenium-webview: - image: healenium/hlm-selenium-4-standalone-tigervnc:firefox98.0.1_chrome99.0.4844.82_edge99.0.1150.46 - restart: on-failure - container_name: hlm-selenium-webview + # Change set up in .env ${CHROME_NODE_IMAGE} to the image you want to use. Mac M1 CPUs require different images. + chrome: + image: ${CHROME_NODE_IMAGE} + container_name: node-chrome + shm_size: 2gb + depends_on: + - selenium-hub + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + networks: + - healenium + + edge: + image: selenium/node-edge:102.0 + container_name: node-edge + shm_size: 2gb + depends_on: + - selenium-hub + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + networks: + - healenium + + firefox: + image: selenium/node-firefox:101.0 + container_name: node-firefox + shm_size: 2gb + depends_on: + - selenium-hub + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + networks: + - healenium + + selenium-hub: + image: selenium/hub:4.3.0 + container_name: selenium-hub ports: - - "8086:6080" + - "4442:4442" + - "4443:4443" - "4444:4444" - volumes: - - docker-log-volume:/var/log/dockerlogs networks: - healenium @@ -74,4 +133,3 @@ volumes: networks: healenium: - \ No newline at end of file