diff --git a/.github/workflows/automation.yml b/.github/workflows/automation.yml index 5a8359f..7f907a1 100644 --- a/.github/workflows/automation.yml +++ b/.github/workflows/automation.yml @@ -8,7 +8,10 @@ on: branches: - main schedule: - - cron: "0 */3 * * *" + - cron: "0 */6 * * *" +concurrency: + group: automation-${{ github.ref }} + cancel-in-progress: true permissions: id-token: write @@ -17,8 +20,12 @@ permissions: jobs: build-and-test: - name: Automation for agencia-clickone + name: Automation runs-on: ubuntu-latest + strategy: + matrix: + browser: [chrome] + client: [agenciaclickone, fracturasyfracturas] timeout-minutes: 5 steps: @@ -29,12 +36,11 @@ jobs: - name: Run automation tests run: | cd automation - ls -la - ./run_tests.sh -S ${{ env.INPUT_SRC }} + ./run_tests.sh -S ${{ env.INPUT_SRC }} -B ${{ matrix.browser }} -C ${{ matrix.client }} env: INPUT_SRC: automation - - name: Upload test results - uses: actions/upload-artifact@v4 - with: - name: github-pages - path: automation/results/ + # - name: Upload test results + # uses: actions/upload-artifact@v4 + # with: + # name: github-pages + # path: automation/results/ diff --git a/Dockerfile b/Dockerfile index cf7ff00..3192d2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,6 +40,16 @@ RUN chown root:root /usr/bin/chromedriver RUN chmod +x /usr/bin/chromedriver RUN rm chromedriver-linux64.zip +RUN curl -L -o firefox-127.0.tar.bz2 "https://download.mozilla.org/?product=firefox-127.0&os=linux64&lang=en-US" +RUN tar xjf firefox-127.0.tar.bz2 -C /opt/ +RUN ln -s /opt/firefox/firefox /usr/local/bin/firefox + +# Download the latest version of geckodriver using curl +ENV GECKODRIVER_VERSION="v0.34.0" +RUN curl -L -o geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz "https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz" +RUN tar -xvzf geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz +RUN mv geckodriver /usr/local/bin/ + # Set environment variables ENV DISPLAY=:99 diff --git a/Tests/chrome/fracturasyfracturas/IndexView.robot b/Tests/chrome/fracturasyfracturas/IndexView.robot new file mode 100644 index 0000000..4697281 --- /dev/null +++ b/Tests/chrome/fracturasyfracturas/IndexView.robot @@ -0,0 +1,26 @@ +*** Settings *** +Documentation Contact Form +Library SeleniumLibrary +Library Process + +*** Variables *** +${BROWSER} chrome + +*** Test Cases *** +Verify contact form render + [Documentation] This test case verifies + [Tags] Functional + + ${chrome_options}= Create Chrome Options + Open Browser https://fracturasyfracturas.com.co/ ${BROWSER} options=${chrome_options} + Wait Until Element Is Visible xpath=//*[@id="agenda"]/div/div[1]/div 30s + [Teardown] Close Browser + +*** Keywords *** +Create Chrome Options + ${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver + Call Method ${options} add_argument --headless + Call Method ${options} add_argument --disable-gpu + Call Method ${options} add_argument --no-sandbox + Call Method ${options} add_argument --disable-dev-shm-usage + RETURN ${options} diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index b31544a..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: '3' - -services: - nextjs-app: - container_name: clickone-automation - build: - context: . - dockerfile: Dockerfile - volumes: - - ./:/app - command: robot -d results /app/Tests - restart: always diff --git a/run_tests.sh b/run_tests.sh index 99d3039..73c5cc8 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash -while getopts "I:S:" flag +while getopts "I:S:B:C:" flag do case "${flag}" in + B) INPUT_BROWSER=${OPTARG};; + C) INPUT_CLIENT=${OPTARG};; S) INPUT_SRC=${OPTARG};; I) INSTALL_PACKAGES=${OPTARG};; *) echo "${OPTARG} is an invalid parameter";; @@ -10,6 +12,8 @@ do done SRC=${INPUT_SRC:=""} +BROWSER=${INPUT_BROWSER:=""} +CLIENT=${INPUT_CLIENT:=""} INSTALL_PACKAGES=true RUN_COMMAND="cd /app/$SRC" @@ -19,7 +23,7 @@ if [ "$INSTALL_PACKAGES" = true ] ; then RUN_COMMAND="${RUN_COMMAND}; ${UPDATE_PACKAGE_MANAGER_CMD}; ${INSTALLATION_PACKAGES_CMD}" fi -RUN_COMMAND="${RUN_COMMAND}; robot -d results Tests" +RUN_COMMAND="${RUN_COMMAND}; robot -d results Tests/${BROWSER}/${CLIENT}" # exit when any command fails set -e